documentation.d.ts 3.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975
  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 in a remote file
  11050. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11051. * @param url defines the url to load from
  11052. * @param scene defines the hosting scene
  11053. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11054. * @returns a promise that will resolve to the new sprite manager
  11055. */
  11056. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11057. /**
  11058. * Creates a sprite manager from a snippet saved by the sprite editor
  11059. * @param snippetId defines the snippet to load
  11060. * @param scene defines the hosting scene
  11061. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11062. * @returns a promise that will resolve to the new sprite manager
  11063. */
  11064. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11065. }
  11066. }
  11067. declare module BABYLON {
  11068. /** Interface used by value gradients (color, factor, ...) */
  11069. export interface IValueGradient {
  11070. /**
  11071. * Gets or sets the gradient value (between 0 and 1)
  11072. */
  11073. gradient: number;
  11074. }
  11075. /** Class used to store color4 gradient */
  11076. export class ColorGradient implements IValueGradient {
  11077. /**
  11078. * Gets or sets the gradient value (between 0 and 1)
  11079. */
  11080. gradient: number;
  11081. /**
  11082. * Gets or sets first associated color
  11083. */
  11084. color1: Color4;
  11085. /**
  11086. * Gets or sets second associated color
  11087. */
  11088. color2?: Color4 | undefined;
  11089. /**
  11090. * Creates a new color4 gradient
  11091. * @param gradient gets or sets the gradient value (between 0 and 1)
  11092. * @param color1 gets or sets first associated color
  11093. * @param color2 gets or sets first second color
  11094. */
  11095. constructor(
  11096. /**
  11097. * Gets or sets the gradient value (between 0 and 1)
  11098. */
  11099. gradient: number,
  11100. /**
  11101. * Gets or sets first associated color
  11102. */
  11103. color1: Color4,
  11104. /**
  11105. * Gets or sets second associated color
  11106. */
  11107. color2?: Color4 | undefined);
  11108. /**
  11109. * Will get a color picked randomly between color1 and color2.
  11110. * If color2 is undefined then color1 will be used
  11111. * @param result defines the target Color4 to store the result in
  11112. */
  11113. getColorToRef(result: Color4): void;
  11114. }
  11115. /** Class used to store color 3 gradient */
  11116. export class Color3Gradient implements IValueGradient {
  11117. /**
  11118. * Gets or sets the gradient value (between 0 and 1)
  11119. */
  11120. gradient: number;
  11121. /**
  11122. * Gets or sets the associated color
  11123. */
  11124. color: Color3;
  11125. /**
  11126. * Creates a new color3 gradient
  11127. * @param gradient gets or sets the gradient value (between 0 and 1)
  11128. * @param color gets or sets associated color
  11129. */
  11130. constructor(
  11131. /**
  11132. * Gets or sets the gradient value (between 0 and 1)
  11133. */
  11134. gradient: number,
  11135. /**
  11136. * Gets or sets the associated color
  11137. */
  11138. color: Color3);
  11139. }
  11140. /** Class used to store factor gradient */
  11141. export class FactorGradient implements IValueGradient {
  11142. /**
  11143. * Gets or sets the gradient value (between 0 and 1)
  11144. */
  11145. gradient: number;
  11146. /**
  11147. * Gets or sets first associated factor
  11148. */
  11149. factor1: number;
  11150. /**
  11151. * Gets or sets second associated factor
  11152. */
  11153. factor2?: number | undefined;
  11154. /**
  11155. * Creates a new factor gradient
  11156. * @param gradient gets or sets the gradient value (between 0 and 1)
  11157. * @param factor1 gets or sets first associated factor
  11158. * @param factor2 gets or sets second associated factor
  11159. */
  11160. constructor(
  11161. /**
  11162. * Gets or sets the gradient value (between 0 and 1)
  11163. */
  11164. gradient: number,
  11165. /**
  11166. * Gets or sets first associated factor
  11167. */
  11168. factor1: number,
  11169. /**
  11170. * Gets or sets second associated factor
  11171. */
  11172. factor2?: number | undefined);
  11173. /**
  11174. * Will get a number picked randomly between factor1 and factor2.
  11175. * If factor2 is undefined then factor1 will be used
  11176. * @returns the picked number
  11177. */
  11178. getFactor(): number;
  11179. }
  11180. /**
  11181. * Helper used to simplify some generic gradient tasks
  11182. */
  11183. export class GradientHelper {
  11184. /**
  11185. * Gets the current gradient from an array of IValueGradient
  11186. * @param ratio defines the current ratio to get
  11187. * @param gradients defines the array of IValueGradient
  11188. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11189. */
  11190. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11191. }
  11192. }
  11193. declare module BABYLON {
  11194. interface ThinEngine {
  11195. /**
  11196. * Creates a dynamic texture
  11197. * @param width defines the width of the texture
  11198. * @param height defines the height of the texture
  11199. * @param generateMipMaps defines if the engine should generate the mip levels
  11200. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11201. * @returns the dynamic texture inside an InternalTexture
  11202. */
  11203. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11204. /**
  11205. * Update the content of a dynamic texture
  11206. * @param texture defines the texture to update
  11207. * @param canvas defines the canvas containing the source
  11208. * @param invertY defines if data must be stored with Y axis inverted
  11209. * @param premulAlpha defines if alpha is stored as premultiplied
  11210. * @param format defines the format of the data
  11211. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11212. */
  11213. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11214. }
  11215. }
  11216. declare module BABYLON {
  11217. /**
  11218. * Helper class used to generate a canvas to manipulate images
  11219. */
  11220. export class CanvasGenerator {
  11221. /**
  11222. * Create a new canvas (or offscreen canvas depending on the context)
  11223. * @param width defines the expected width
  11224. * @param height defines the expected height
  11225. * @return a new canvas or offscreen canvas
  11226. */
  11227. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11228. }
  11229. }
  11230. declare module BABYLON {
  11231. /**
  11232. * A class extending Texture allowing drawing on a texture
  11233. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11234. */
  11235. export class DynamicTexture extends Texture {
  11236. private _generateMipMaps;
  11237. private _canvas;
  11238. private _context;
  11239. /**
  11240. * Creates a DynamicTexture
  11241. * @param name defines the name of the texture
  11242. * @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
  11243. * @param scene defines the scene where you want the texture
  11244. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11245. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11246. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11247. */
  11248. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11249. /**
  11250. * Get the current class name of the texture useful for serialization or dynamic coding.
  11251. * @returns "DynamicTexture"
  11252. */
  11253. getClassName(): string;
  11254. /**
  11255. * Gets the current state of canRescale
  11256. */
  11257. get canRescale(): boolean;
  11258. private _recreate;
  11259. /**
  11260. * Scales the texture
  11261. * @param ratio the scale factor to apply to both width and height
  11262. */
  11263. scale(ratio: number): void;
  11264. /**
  11265. * Resizes the texture
  11266. * @param width the new width
  11267. * @param height the new height
  11268. */
  11269. scaleTo(width: number, height: number): void;
  11270. /**
  11271. * Gets the context of the canvas used by the texture
  11272. * @returns the canvas context of the dynamic texture
  11273. */
  11274. getContext(): CanvasRenderingContext2D;
  11275. /**
  11276. * Clears the texture
  11277. */
  11278. clear(): void;
  11279. /**
  11280. * Updates the texture
  11281. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11282. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11283. */
  11284. update(invertY?: boolean, premulAlpha?: boolean): void;
  11285. /**
  11286. * Draws text onto the texture
  11287. * @param text defines the text to be drawn
  11288. * @param x defines the placement of the text from the left
  11289. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11290. * @param font defines the font to be used with font-style, font-size, font-name
  11291. * @param color defines the color used for the text
  11292. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11293. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11294. * @param update defines whether texture is immediately update (default is true)
  11295. */
  11296. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11297. /**
  11298. * Clones the texture
  11299. * @returns the clone of the texture.
  11300. */
  11301. clone(): DynamicTexture;
  11302. /**
  11303. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11304. * @returns a serialized dynamic texture object
  11305. */
  11306. serialize(): any;
  11307. /** @hidden */
  11308. _rebuild(): void;
  11309. }
  11310. }
  11311. declare module BABYLON {
  11312. interface ThinEngine {
  11313. /**
  11314. * Creates a raw texture
  11315. * @param data defines the data to store in the texture
  11316. * @param width defines the width of the texture
  11317. * @param height defines the height of the texture
  11318. * @param format defines the format of the data
  11319. * @param generateMipMaps defines if the engine should generate the mip levels
  11320. * @param invertY defines if data must be stored with Y axis inverted
  11321. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11322. * @param compression defines the compression used (null by default)
  11323. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11324. * @returns the raw texture inside an InternalTexture
  11325. */
  11326. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11327. /**
  11328. * Update a raw texture
  11329. * @param texture defines the texture to update
  11330. * @param data defines the data to store in the texture
  11331. * @param format defines the format of the data
  11332. * @param invertY defines if data must be stored with Y axis inverted
  11333. */
  11334. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11335. /**
  11336. * Update a raw texture
  11337. * @param texture defines the texture to update
  11338. * @param data defines the data to store in the texture
  11339. * @param format defines the format of the data
  11340. * @param invertY defines if data must be stored with Y axis inverted
  11341. * @param compression defines the compression used (null by default)
  11342. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11343. */
  11344. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11345. /**
  11346. * Creates a new raw cube texture
  11347. * @param data defines the array of data to use to create each face
  11348. * @param size defines the size of the textures
  11349. * @param format defines the format of the data
  11350. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11351. * @param generateMipMaps defines if the engine should generate the mip levels
  11352. * @param invertY defines if data must be stored with Y axis inverted
  11353. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11354. * @param compression defines the compression used (null by default)
  11355. * @returns the cube texture as an InternalTexture
  11356. */
  11357. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  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. */
  11366. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11367. /**
  11368. * Update a raw cube texture
  11369. * @param texture defines the texture to udpdate
  11370. * @param data defines the data to store
  11371. * @param format defines the data format
  11372. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11373. * @param invertY defines if data must be stored with Y axis inverted
  11374. * @param compression defines the compression used (null by default)
  11375. */
  11376. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11377. /**
  11378. * Update a raw cube texture
  11379. * @param texture defines the texture to udpdate
  11380. * @param data defines the data to store
  11381. * @param format defines the data format
  11382. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11383. * @param invertY defines if data must be stored with Y axis inverted
  11384. * @param compression defines the compression used (null by default)
  11385. * @param level defines which level of the texture to update
  11386. */
  11387. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11388. /**
  11389. * Creates a new raw cube texture from a specified url
  11390. * @param url defines the url where the data is located
  11391. * @param scene defines the current scene
  11392. * @param size defines the size of the textures
  11393. * @param format defines the format of the data
  11394. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11395. * @param noMipmap defines if the engine should avoid generating the mip levels
  11396. * @param callback defines a callback used to extract texture data from loaded data
  11397. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11398. * @param onLoad defines a callback called when texture is loaded
  11399. * @param onError defines a callback called if there is an error
  11400. * @returns the cube texture as an InternalTexture
  11401. */
  11402. 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;
  11403. /**
  11404. * Creates a new raw cube texture from a specified url
  11405. * @param url defines the url where the data is located
  11406. * @param scene defines the current scene
  11407. * @param size defines the size of the textures
  11408. * @param format defines the format of the data
  11409. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11410. * @param noMipmap defines if the engine should avoid generating the mip levels
  11411. * @param callback defines a callback used to extract texture data from loaded data
  11412. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11413. * @param onLoad defines a callback called when texture is loaded
  11414. * @param onError defines a callback called if there is an error
  11415. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11416. * @param invertY defines if data must be stored with Y axis inverted
  11417. * @returns the cube texture as an InternalTexture
  11418. */
  11419. 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;
  11420. /**
  11421. * Creates a new raw 3D texture
  11422. * @param data defines the data used to create the texture
  11423. * @param width defines the width of the texture
  11424. * @param height defines the height of the texture
  11425. * @param depth defines the depth of the texture
  11426. * @param format defines the format of the texture
  11427. * @param generateMipMaps defines if the engine must generate mip levels
  11428. * @param invertY defines if data must be stored with Y axis inverted
  11429. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11430. * @param compression defines the compressed used (can be null)
  11431. * @param textureType defines the compressed used (can be null)
  11432. * @returns a new raw 3D texture (stored in an InternalTexture)
  11433. */
  11434. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11435. /**
  11436. * Update a raw 3D texture
  11437. * @param texture defines the texture to update
  11438. * @param data defines the data to store
  11439. * @param format defines the data format
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. */
  11442. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11443. /**
  11444. * Update a raw 3D texture
  11445. * @param texture defines the texture to update
  11446. * @param data defines the data to store
  11447. * @param format defines the data format
  11448. * @param invertY defines if data must be stored with Y axis inverted
  11449. * @param compression defines the used compression (can be null)
  11450. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11451. */
  11452. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11453. /**
  11454. * Creates a new raw 2D array texture
  11455. * @param data defines the data used to create the texture
  11456. * @param width defines the width of the texture
  11457. * @param height defines the height of the texture
  11458. * @param depth defines the number of layers of the texture
  11459. * @param format defines the format of the texture
  11460. * @param generateMipMaps defines if the engine must generate mip levels
  11461. * @param invertY defines if data must be stored with Y axis inverted
  11462. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11463. * @param compression defines the compressed used (can be null)
  11464. * @param textureType defines the compressed used (can be null)
  11465. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11466. */
  11467. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11468. /**
  11469. * Update a raw 2D array texture
  11470. * @param texture defines the texture to update
  11471. * @param data defines the data to store
  11472. * @param format defines the data format
  11473. * @param invertY defines if data must be stored with Y axis inverted
  11474. */
  11475. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11476. /**
  11477. * Update a raw 2D array texture
  11478. * @param texture defines the texture to update
  11479. * @param data defines the data to store
  11480. * @param format defines the data format
  11481. * @param invertY defines if data must be stored with Y axis inverted
  11482. * @param compression defines the used compression (can be null)
  11483. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11484. */
  11485. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11486. }
  11487. }
  11488. declare module BABYLON {
  11489. /**
  11490. * Raw texture can help creating a texture directly from an array of data.
  11491. * This can be super useful if you either get the data from an uncompressed source or
  11492. * if you wish to create your texture pixel by pixel.
  11493. */
  11494. export class RawTexture extends Texture {
  11495. /**
  11496. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11497. */
  11498. format: number;
  11499. /**
  11500. * Instantiates a new RawTexture.
  11501. * Raw texture can help creating a texture directly from an array of data.
  11502. * This can be super useful if you either get the data from an uncompressed source or
  11503. * if you wish to create your texture pixel by pixel.
  11504. * @param data define the array of data to use to create the texture
  11505. * @param width define the width of the texture
  11506. * @param height define the height of the texture
  11507. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11508. * @param scene define the scene the texture belongs to
  11509. * @param generateMipMaps define whether mip maps should be generated or not
  11510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11512. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11513. */
  11514. constructor(data: ArrayBufferView, width: number, height: number,
  11515. /**
  11516. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11517. */
  11518. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11519. /**
  11520. * Updates the texture underlying data.
  11521. * @param data Define the new data of the texture
  11522. */
  11523. update(data: ArrayBufferView): void;
  11524. /**
  11525. * Creates a luminance texture from some data.
  11526. * @param data Define the texture data
  11527. * @param width Define the width of the texture
  11528. * @param height Define the height of the texture
  11529. * @param scene Define the scene the texture belongs to
  11530. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11531. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11532. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11533. * @returns the luminance texture
  11534. */
  11535. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11536. /**
  11537. * Creates a luminance alpha texture from some data.
  11538. * @param data Define the texture data
  11539. * @param width Define the width of the texture
  11540. * @param height Define the height of the texture
  11541. * @param scene Define the scene the texture belongs to
  11542. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11543. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11544. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11545. * @returns the luminance alpha texture
  11546. */
  11547. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11548. /**
  11549. * Creates an alpha texture from some data.
  11550. * @param data Define the texture data
  11551. * @param width Define the width of the texture
  11552. * @param height Define the height of the texture
  11553. * @param scene Define the scene the texture belongs to
  11554. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11555. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11556. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11557. * @returns the alpha texture
  11558. */
  11559. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11560. /**
  11561. * Creates a RGB texture from some data.
  11562. * @param data Define the texture data
  11563. * @param width Define the width of the texture
  11564. * @param height Define the height of the texture
  11565. * @param scene Define the scene the texture belongs to
  11566. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11569. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11570. * @returns the RGB alpha texture
  11571. */
  11572. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11573. /**
  11574. * Creates a RGBA texture from some data.
  11575. * @param data Define the texture data
  11576. * @param width Define the width of the texture
  11577. * @param height Define the height of the texture
  11578. * @param scene Define the scene the texture belongs to
  11579. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11582. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11583. * @returns the RGBA texture
  11584. */
  11585. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11586. /**
  11587. * Creates a R texture from some data.
  11588. * @param data Define the texture data
  11589. * @param width Define the width of the texture
  11590. * @param height Define the height of the texture
  11591. * @param scene Define the scene the texture belongs to
  11592. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11593. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11594. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11595. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11596. * @returns the R texture
  11597. */
  11598. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11599. }
  11600. }
  11601. declare module BABYLON {
  11602. interface AbstractScene {
  11603. /**
  11604. * The list of procedural textures added to the scene
  11605. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11606. */
  11607. proceduralTextures: Array<ProceduralTexture>;
  11608. }
  11609. /**
  11610. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11611. * in a given scene.
  11612. */
  11613. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11614. /**
  11615. * The component name helpfull to identify the component in the list of scene components.
  11616. */
  11617. readonly name: string;
  11618. /**
  11619. * The scene the component belongs to.
  11620. */
  11621. scene: Scene;
  11622. /**
  11623. * Creates a new instance of the component for the given scene
  11624. * @param scene Defines the scene to register the component in
  11625. */
  11626. constructor(scene: Scene);
  11627. /**
  11628. * Registers the component in a given scene
  11629. */
  11630. register(): void;
  11631. /**
  11632. * Rebuilds the elements related to this component in case of
  11633. * context lost for instance.
  11634. */
  11635. rebuild(): void;
  11636. /**
  11637. * Disposes the component and the associated ressources.
  11638. */
  11639. dispose(): void;
  11640. private _beforeClear;
  11641. }
  11642. }
  11643. declare module BABYLON {
  11644. interface ThinEngine {
  11645. /**
  11646. * Creates a new render target cube texture
  11647. * @param size defines the size of the texture
  11648. * @param options defines the options used to create the texture
  11649. * @returns a new render target cube texture stored in an InternalTexture
  11650. */
  11651. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11652. }
  11653. }
  11654. declare module BABYLON {
  11655. /** @hidden */
  11656. export var proceduralVertexShader: {
  11657. name: string;
  11658. shader: string;
  11659. };
  11660. }
  11661. declare module BABYLON {
  11662. /**
  11663. * 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.
  11664. * This is the base class of any Procedural texture and contains most of the shareable code.
  11665. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11666. */
  11667. export class ProceduralTexture extends Texture {
  11668. isCube: boolean;
  11669. /**
  11670. * Define if the texture is enabled or not (disabled texture will not render)
  11671. */
  11672. isEnabled: boolean;
  11673. /**
  11674. * Define if the texture must be cleared before rendering (default is true)
  11675. */
  11676. autoClear: boolean;
  11677. /**
  11678. * Callback called when the texture is generated
  11679. */
  11680. onGenerated: () => void;
  11681. /**
  11682. * Event raised when the texture is generated
  11683. */
  11684. onGeneratedObservable: Observable<ProceduralTexture>;
  11685. /** @hidden */
  11686. _generateMipMaps: boolean;
  11687. /** @hidden **/
  11688. _effect: Effect;
  11689. /** @hidden */
  11690. _textures: {
  11691. [key: string]: Texture;
  11692. };
  11693. /** @hidden */
  11694. protected _fallbackTexture: Nullable<Texture>;
  11695. private _size;
  11696. private _currentRefreshId;
  11697. private _frameId;
  11698. private _refreshRate;
  11699. private _vertexBuffers;
  11700. private _indexBuffer;
  11701. private _uniforms;
  11702. private _samplers;
  11703. private _fragment;
  11704. private _floats;
  11705. private _ints;
  11706. private _floatsArrays;
  11707. private _colors3;
  11708. private _colors4;
  11709. private _vectors2;
  11710. private _vectors3;
  11711. private _matrices;
  11712. private _fallbackTextureUsed;
  11713. private _fullEngine;
  11714. private _cachedDefines;
  11715. private _contentUpdateId;
  11716. private _contentData;
  11717. /**
  11718. * Instantiates a new procedural texture.
  11719. * 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.
  11720. * This is the base class of any Procedural texture and contains most of the shareable code.
  11721. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11722. * @param name Define the name of the texture
  11723. * @param size Define the size of the texture to create
  11724. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11725. * @param scene Define the scene the texture belongs to
  11726. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11727. * @param generateMipMaps Define if the texture should creates mip maps or not
  11728. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11729. */
  11730. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11731. /**
  11732. * The effect that is created when initializing the post process.
  11733. * @returns The created effect corresponding the the postprocess.
  11734. */
  11735. getEffect(): Effect;
  11736. /**
  11737. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11738. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11739. */
  11740. getContent(): Nullable<ArrayBufferView>;
  11741. private _createIndexBuffer;
  11742. /** @hidden */
  11743. _rebuild(): void;
  11744. /**
  11745. * Resets the texture in order to recreate its associated resources.
  11746. * This can be called in case of context loss
  11747. */
  11748. reset(): void;
  11749. protected _getDefines(): string;
  11750. /**
  11751. * Is the texture ready to be used ? (rendered at least once)
  11752. * @returns true if ready, otherwise, false.
  11753. */
  11754. isReady(): boolean;
  11755. /**
  11756. * Resets the refresh counter of the texture and start bak from scratch.
  11757. * Could be useful to regenerate the texture if it is setup to render only once.
  11758. */
  11759. resetRefreshCounter(): void;
  11760. /**
  11761. * Set the fragment shader to use in order to render the texture.
  11762. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11763. */
  11764. setFragment(fragment: any): void;
  11765. /**
  11766. * Define the refresh rate of the texture or the rendering frequency.
  11767. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11768. */
  11769. get refreshRate(): number;
  11770. set refreshRate(value: number);
  11771. /** @hidden */
  11772. _shouldRender(): boolean;
  11773. /**
  11774. * Get the size the texture is rendering at.
  11775. * @returns the size (texture is always squared)
  11776. */
  11777. getRenderSize(): number;
  11778. /**
  11779. * Resize the texture to new value.
  11780. * @param size Define the new size the texture should have
  11781. * @param generateMipMaps Define whether the new texture should create mip maps
  11782. */
  11783. resize(size: number, generateMipMaps: boolean): void;
  11784. private _checkUniform;
  11785. /**
  11786. * Set a texture in the shader program used to render.
  11787. * @param name Define the name of the uniform samplers as defined in the shader
  11788. * @param texture Define the texture to bind to this sampler
  11789. * @return the texture itself allowing "fluent" like uniform updates
  11790. */
  11791. setTexture(name: string, texture: Texture): ProceduralTexture;
  11792. /**
  11793. * Set a float in the shader.
  11794. * @param name Define the name of the uniform as defined in the shader
  11795. * @param value Define the value to give to the uniform
  11796. * @return the texture itself allowing "fluent" like uniform updates
  11797. */
  11798. setFloat(name: string, value: number): ProceduralTexture;
  11799. /**
  11800. * Set a int in the shader.
  11801. * @param name Define the name of the uniform as defined in the shader
  11802. * @param value Define the value to give to the uniform
  11803. * @return the texture itself allowing "fluent" like uniform updates
  11804. */
  11805. setInt(name: string, value: number): ProceduralTexture;
  11806. /**
  11807. * Set an array of floats in the shader.
  11808. * @param name Define the name of the uniform as defined in the shader
  11809. * @param value Define the value to give to the uniform
  11810. * @return the texture itself allowing "fluent" like uniform updates
  11811. */
  11812. setFloats(name: string, value: number[]): ProceduralTexture;
  11813. /**
  11814. * Set a vec3 in the shader from a Color3.
  11815. * @param name Define the name of the uniform as defined in the shader
  11816. * @param value Define the value to give to the uniform
  11817. * @return the texture itself allowing "fluent" like uniform updates
  11818. */
  11819. setColor3(name: string, value: Color3): ProceduralTexture;
  11820. /**
  11821. * Set a vec4 in the shader from a Color4.
  11822. * @param name Define the name of the uniform as defined in the shader
  11823. * @param value Define the value to give to the uniform
  11824. * @return the texture itself allowing "fluent" like uniform updates
  11825. */
  11826. setColor4(name: string, value: Color4): ProceduralTexture;
  11827. /**
  11828. * Set a vec2 in the shader from a Vector2.
  11829. * @param name Define the name of the uniform as defined in the shader
  11830. * @param value Define the value to give to the uniform
  11831. * @return the texture itself allowing "fluent" like uniform updates
  11832. */
  11833. setVector2(name: string, value: Vector2): ProceduralTexture;
  11834. /**
  11835. * Set a vec3 in the shader from a Vector3.
  11836. * @param name Define the name of the uniform as defined in the shader
  11837. * @param value Define the value to give to the uniform
  11838. * @return the texture itself allowing "fluent" like uniform updates
  11839. */
  11840. setVector3(name: string, value: Vector3): ProceduralTexture;
  11841. /**
  11842. * Set a mat4 in the shader from a MAtrix.
  11843. * @param name Define the name of the uniform as defined in the shader
  11844. * @param value Define the value to give to the uniform
  11845. * @return the texture itself allowing "fluent" like uniform updates
  11846. */
  11847. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11848. /**
  11849. * Render the texture to its associated render target.
  11850. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11851. */
  11852. render(useCameraPostProcess?: boolean): void;
  11853. /**
  11854. * Clone the texture.
  11855. * @returns the cloned texture
  11856. */
  11857. clone(): ProceduralTexture;
  11858. /**
  11859. * Dispose the texture and release its asoociated resources.
  11860. */
  11861. dispose(): void;
  11862. }
  11863. }
  11864. declare module BABYLON {
  11865. /**
  11866. * This represents the base class for particle system in Babylon.
  11867. * 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.
  11868. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11869. * @example https://doc.babylonjs.com/babylon101/particles
  11870. */
  11871. export class BaseParticleSystem {
  11872. /**
  11873. * Source color is added to the destination color without alpha affecting the result
  11874. */
  11875. static BLENDMODE_ONEONE: number;
  11876. /**
  11877. * Blend current color and particle color using particle’s alpha
  11878. */
  11879. static BLENDMODE_STANDARD: number;
  11880. /**
  11881. * Add current color and particle color multiplied by particle’s alpha
  11882. */
  11883. static BLENDMODE_ADD: number;
  11884. /**
  11885. * Multiply current color with particle color
  11886. */
  11887. static BLENDMODE_MULTIPLY: number;
  11888. /**
  11889. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11890. */
  11891. static BLENDMODE_MULTIPLYADD: number;
  11892. /**
  11893. * List of animations used by the particle system.
  11894. */
  11895. animations: Animation[];
  11896. /**
  11897. * Gets or sets the unique id of the particle system
  11898. */
  11899. uniqueId: number;
  11900. /**
  11901. * The id of the Particle system.
  11902. */
  11903. id: string;
  11904. /**
  11905. * The friendly name of the Particle system.
  11906. */
  11907. name: string;
  11908. /**
  11909. * Snippet ID if the particle system was created from the snippet server
  11910. */
  11911. snippetId: string;
  11912. /**
  11913. * The rendering group used by the Particle system to chose when to render.
  11914. */
  11915. renderingGroupId: number;
  11916. /**
  11917. * The emitter represents the Mesh or position we are attaching the particle system to.
  11918. */
  11919. emitter: Nullable<AbstractMesh | Vector3>;
  11920. /**
  11921. * The maximum number of particles to emit per frame
  11922. */
  11923. emitRate: number;
  11924. /**
  11925. * If you want to launch only a few particles at once, that can be done, as well.
  11926. */
  11927. manualEmitCount: number;
  11928. /**
  11929. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11930. */
  11931. updateSpeed: number;
  11932. /**
  11933. * The amount of time the particle system is running (depends of the overall update speed).
  11934. */
  11935. targetStopDuration: number;
  11936. /**
  11937. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11938. */
  11939. disposeOnStop: boolean;
  11940. /**
  11941. * Minimum power of emitting particles.
  11942. */
  11943. minEmitPower: number;
  11944. /**
  11945. * Maximum power of emitting particles.
  11946. */
  11947. maxEmitPower: number;
  11948. /**
  11949. * Minimum life time of emitting particles.
  11950. */
  11951. minLifeTime: number;
  11952. /**
  11953. * Maximum life time of emitting particles.
  11954. */
  11955. maxLifeTime: number;
  11956. /**
  11957. * Minimum Size of emitting particles.
  11958. */
  11959. minSize: number;
  11960. /**
  11961. * Maximum Size of emitting particles.
  11962. */
  11963. maxSize: number;
  11964. /**
  11965. * Minimum scale of emitting particles on X axis.
  11966. */
  11967. minScaleX: number;
  11968. /**
  11969. * Maximum scale of emitting particles on X axis.
  11970. */
  11971. maxScaleX: number;
  11972. /**
  11973. * Minimum scale of emitting particles on Y axis.
  11974. */
  11975. minScaleY: number;
  11976. /**
  11977. * Maximum scale of emitting particles on Y axis.
  11978. */
  11979. maxScaleY: number;
  11980. /**
  11981. * Gets or sets the minimal initial rotation in radians.
  11982. */
  11983. minInitialRotation: number;
  11984. /**
  11985. * Gets or sets the maximal initial rotation in radians.
  11986. */
  11987. maxInitialRotation: number;
  11988. /**
  11989. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11990. */
  11991. minAngularSpeed: number;
  11992. /**
  11993. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11994. */
  11995. maxAngularSpeed: number;
  11996. /**
  11997. * The texture used to render each particle. (this can be a spritesheet)
  11998. */
  11999. particleTexture: Nullable<Texture>;
  12000. /**
  12001. * The layer mask we are rendering the particles through.
  12002. */
  12003. layerMask: number;
  12004. /**
  12005. * This can help using your own shader to render the particle system.
  12006. * The according effect will be created
  12007. */
  12008. customShader: any;
  12009. /**
  12010. * By default particle system starts as soon as they are created. This prevents the
  12011. * automatic start to happen and let you decide when to start emitting particles.
  12012. */
  12013. preventAutoStart: boolean;
  12014. private _noiseTexture;
  12015. /**
  12016. * Gets or sets a texture used to add random noise to particle positions
  12017. */
  12018. get noiseTexture(): Nullable<ProceduralTexture>;
  12019. set noiseTexture(value: Nullable<ProceduralTexture>);
  12020. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12021. noiseStrength: Vector3;
  12022. /**
  12023. * Callback triggered when the particle animation is ending.
  12024. */
  12025. onAnimationEnd: Nullable<() => void>;
  12026. /**
  12027. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12028. */
  12029. blendMode: number;
  12030. /**
  12031. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12032. * to override the particles.
  12033. */
  12034. forceDepthWrite: boolean;
  12035. /** 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 */
  12036. preWarmCycles: number;
  12037. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12038. preWarmStepOffset: number;
  12039. /**
  12040. * 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)
  12041. */
  12042. spriteCellChangeSpeed: number;
  12043. /**
  12044. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12045. */
  12046. startSpriteCellID: number;
  12047. /**
  12048. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12049. */
  12050. endSpriteCellID: number;
  12051. /**
  12052. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12053. */
  12054. spriteCellWidth: number;
  12055. /**
  12056. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12057. */
  12058. spriteCellHeight: number;
  12059. /**
  12060. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12061. */
  12062. spriteRandomStartCell: boolean;
  12063. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12064. translationPivot: Vector2;
  12065. /** @hidden */
  12066. protected _isAnimationSheetEnabled: boolean;
  12067. /**
  12068. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12069. */
  12070. beginAnimationOnStart: boolean;
  12071. /**
  12072. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12073. */
  12074. beginAnimationFrom: number;
  12075. /**
  12076. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12077. */
  12078. beginAnimationTo: number;
  12079. /**
  12080. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12081. */
  12082. beginAnimationLoop: boolean;
  12083. /**
  12084. * Gets or sets a world offset applied to all particles
  12085. */
  12086. worldOffset: Vector3;
  12087. /**
  12088. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12089. */
  12090. get isAnimationSheetEnabled(): boolean;
  12091. set isAnimationSheetEnabled(value: boolean);
  12092. /**
  12093. * Get hosting scene
  12094. * @returns the scene
  12095. */
  12096. getScene(): Scene;
  12097. /**
  12098. * You can use gravity if you want to give an orientation to your particles.
  12099. */
  12100. gravity: Vector3;
  12101. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12102. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12103. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12104. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12105. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12106. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12107. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12108. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12109. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12110. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12111. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12112. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12113. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12114. /**
  12115. * Defines the delay in milliseconds before starting the system (0 by default)
  12116. */
  12117. startDelay: number;
  12118. /**
  12119. * Gets the current list of drag gradients.
  12120. * You must use addDragGradient and removeDragGradient to udpate this list
  12121. * @returns the list of drag gradients
  12122. */
  12123. getDragGradients(): Nullable<Array<FactorGradient>>;
  12124. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12125. limitVelocityDamping: number;
  12126. /**
  12127. * Gets the current list of limit velocity gradients.
  12128. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12129. * @returns the list of limit velocity gradients
  12130. */
  12131. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12132. /**
  12133. * Gets the current list of color gradients.
  12134. * You must use addColorGradient and removeColorGradient to udpate this list
  12135. * @returns the list of color gradients
  12136. */
  12137. getColorGradients(): Nullable<Array<ColorGradient>>;
  12138. /**
  12139. * Gets the current list of size gradients.
  12140. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12141. * @returns the list of size gradients
  12142. */
  12143. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12144. /**
  12145. * Gets the current list of color remap gradients.
  12146. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12147. * @returns the list of color remap gradients
  12148. */
  12149. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12150. /**
  12151. * Gets the current list of alpha remap gradients.
  12152. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12153. * @returns the list of alpha remap gradients
  12154. */
  12155. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12156. /**
  12157. * Gets the current list of life time gradients.
  12158. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12159. * @returns the list of life time gradients
  12160. */
  12161. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12162. /**
  12163. * Gets the current list of angular speed gradients.
  12164. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12165. * @returns the list of angular speed gradients
  12166. */
  12167. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12168. /**
  12169. * Gets the current list of velocity gradients.
  12170. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12171. * @returns the list of velocity gradients
  12172. */
  12173. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12174. /**
  12175. * Gets the current list of start size gradients.
  12176. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12177. * @returns the list of start size gradients
  12178. */
  12179. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12180. /**
  12181. * Gets the current list of emit rate gradients.
  12182. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12183. * @returns the list of emit rate gradients
  12184. */
  12185. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12186. /**
  12187. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12188. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12189. */
  12190. get direction1(): Vector3;
  12191. set direction1(value: Vector3);
  12192. /**
  12193. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12194. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12195. */
  12196. get direction2(): Vector3;
  12197. set direction2(value: Vector3);
  12198. /**
  12199. * 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.
  12200. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12201. */
  12202. get minEmitBox(): Vector3;
  12203. set minEmitBox(value: Vector3);
  12204. /**
  12205. * 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.
  12206. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12207. */
  12208. get maxEmitBox(): Vector3;
  12209. set maxEmitBox(value: Vector3);
  12210. /**
  12211. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12212. */
  12213. color1: Color4;
  12214. /**
  12215. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12216. */
  12217. color2: Color4;
  12218. /**
  12219. * Color the particle will have at the end of its lifetime
  12220. */
  12221. colorDead: Color4;
  12222. /**
  12223. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12224. */
  12225. textureMask: Color4;
  12226. /**
  12227. * The particle emitter type defines the emitter used by the particle system.
  12228. * It can be for example box, sphere, or cone...
  12229. */
  12230. particleEmitterType: IParticleEmitterType;
  12231. /** @hidden */
  12232. _isSubEmitter: boolean;
  12233. /**
  12234. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12235. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12236. */
  12237. billboardMode: number;
  12238. protected _isBillboardBased: boolean;
  12239. /**
  12240. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12241. */
  12242. get isBillboardBased(): boolean;
  12243. set isBillboardBased(value: boolean);
  12244. /**
  12245. * The scene the particle system belongs to.
  12246. */
  12247. protected _scene: Scene;
  12248. /**
  12249. * Local cache of defines for image processing.
  12250. */
  12251. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12252. /**
  12253. * Default configuration related to image processing available in the standard Material.
  12254. */
  12255. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12256. /**
  12257. * Gets the image processing configuration used either in this material.
  12258. */
  12259. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12260. /**
  12261. * Sets the Default image processing configuration used either in the this material.
  12262. *
  12263. * If sets to null, the scene one is in use.
  12264. */
  12265. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12266. /**
  12267. * Attaches a new image processing configuration to the Standard Material.
  12268. * @param configuration
  12269. */
  12270. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12271. /** @hidden */
  12272. protected _reset(): void;
  12273. /** @hidden */
  12274. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12275. /**
  12276. * Instantiates a particle system.
  12277. * 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.
  12278. * @param name The name of the particle system
  12279. */
  12280. constructor(name: string);
  12281. /**
  12282. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12283. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12284. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12285. * @returns the emitter
  12286. */
  12287. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12288. /**
  12289. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12290. * @param radius The radius of the hemisphere to emit from
  12291. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12292. * @returns the emitter
  12293. */
  12294. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12295. /**
  12296. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12297. * @param radius The radius of the sphere to emit from
  12298. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12299. * @returns the emitter
  12300. */
  12301. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12302. /**
  12303. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12304. * @param radius The radius of the sphere to emit from
  12305. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12306. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12307. * @returns the emitter
  12308. */
  12309. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12310. /**
  12311. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12312. * @param radius The radius of the emission cylinder
  12313. * @param height The height of the emission cylinder
  12314. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12315. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12316. * @returns the emitter
  12317. */
  12318. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12319. /**
  12320. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12321. * @param radius The radius of the cylinder to emit from
  12322. * @param height The height of the emission cylinder
  12323. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12324. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12325. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12326. * @returns the emitter
  12327. */
  12328. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12329. /**
  12330. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12331. * @param radius The radius of the cone to emit from
  12332. * @param angle The base angle of the cone
  12333. * @returns the emitter
  12334. */
  12335. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12336. /**
  12337. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12338. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12339. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12340. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12341. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12342. * @returns the emitter
  12343. */
  12344. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12345. }
  12346. }
  12347. declare module BABYLON {
  12348. /**
  12349. * Type of sub emitter
  12350. */
  12351. export enum SubEmitterType {
  12352. /**
  12353. * Attached to the particle over it's lifetime
  12354. */
  12355. ATTACHED = 0,
  12356. /**
  12357. * Created when the particle dies
  12358. */
  12359. END = 1
  12360. }
  12361. /**
  12362. * Sub emitter class used to emit particles from an existing particle
  12363. */
  12364. export class SubEmitter {
  12365. /**
  12366. * the particle system to be used by the sub emitter
  12367. */
  12368. particleSystem: ParticleSystem;
  12369. /**
  12370. * Type of the submitter (Default: END)
  12371. */
  12372. type: SubEmitterType;
  12373. /**
  12374. * 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)
  12375. * Note: This only is supported when using an emitter of type Mesh
  12376. */
  12377. inheritDirection: boolean;
  12378. /**
  12379. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12380. */
  12381. inheritedVelocityAmount: number;
  12382. /**
  12383. * Creates a sub emitter
  12384. * @param particleSystem the particle system to be used by the sub emitter
  12385. */
  12386. constructor(
  12387. /**
  12388. * the particle system to be used by the sub emitter
  12389. */
  12390. particleSystem: ParticleSystem);
  12391. /**
  12392. * Clones the sub emitter
  12393. * @returns the cloned sub emitter
  12394. */
  12395. clone(): SubEmitter;
  12396. /**
  12397. * Serialize current object to a JSON object
  12398. * @returns the serialized object
  12399. */
  12400. serialize(): any;
  12401. /** @hidden */
  12402. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12403. /**
  12404. * Creates a new SubEmitter from a serialized JSON version
  12405. * @param serializationObject defines the JSON object to read from
  12406. * @param scene defines the hosting scene
  12407. * @param rootUrl defines the rootUrl for data loading
  12408. * @returns a new SubEmitter
  12409. */
  12410. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12411. /** Release associated resources */
  12412. dispose(): void;
  12413. }
  12414. }
  12415. declare module BABYLON {
  12416. /** @hidden */
  12417. export var imageProcessingDeclaration: {
  12418. name: string;
  12419. shader: string;
  12420. };
  12421. }
  12422. declare module BABYLON {
  12423. /** @hidden */
  12424. export var imageProcessingFunctions: {
  12425. name: string;
  12426. shader: string;
  12427. };
  12428. }
  12429. declare module BABYLON {
  12430. /** @hidden */
  12431. export var particlesPixelShader: {
  12432. name: string;
  12433. shader: string;
  12434. };
  12435. }
  12436. declare module BABYLON {
  12437. /** @hidden */
  12438. export var particlesVertexShader: {
  12439. name: string;
  12440. shader: string;
  12441. };
  12442. }
  12443. declare module BABYLON {
  12444. /**
  12445. * This represents a particle system in Babylon.
  12446. * 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.
  12447. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12448. * @example https://doc.babylonjs.com/babylon101/particles
  12449. */
  12450. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12451. /**
  12452. * Billboard mode will only apply to Y axis
  12453. */
  12454. static readonly BILLBOARDMODE_Y: number;
  12455. /**
  12456. * Billboard mode will apply to all axes
  12457. */
  12458. static readonly BILLBOARDMODE_ALL: number;
  12459. /**
  12460. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12461. */
  12462. static readonly BILLBOARDMODE_STRETCHED: number;
  12463. /**
  12464. * This function can be defined to provide custom update for active particles.
  12465. * This function will be called instead of regular update (age, position, color, etc.).
  12466. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12467. */
  12468. updateFunction: (particles: Particle[]) => void;
  12469. private _emitterWorldMatrix;
  12470. /**
  12471. * This function can be defined to specify initial direction for every new particle.
  12472. * It by default use the emitterType defined function
  12473. */
  12474. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12475. /**
  12476. * This function can be defined to specify initial position for every new particle.
  12477. * It by default use the emitterType defined function
  12478. */
  12479. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12480. /**
  12481. * @hidden
  12482. */
  12483. _inheritedVelocityOffset: Vector3;
  12484. /**
  12485. * An event triggered when the system is disposed
  12486. */
  12487. onDisposeObservable: Observable<IParticleSystem>;
  12488. private _onDisposeObserver;
  12489. /**
  12490. * Sets a callback that will be triggered when the system is disposed
  12491. */
  12492. set onDispose(callback: () => void);
  12493. private _particles;
  12494. private _epsilon;
  12495. private _capacity;
  12496. private _stockParticles;
  12497. private _newPartsExcess;
  12498. private _vertexData;
  12499. private _vertexBuffer;
  12500. private _vertexBuffers;
  12501. private _spriteBuffer;
  12502. private _indexBuffer;
  12503. private _effect;
  12504. private _customEffect;
  12505. private _cachedDefines;
  12506. private _scaledColorStep;
  12507. private _colorDiff;
  12508. private _scaledDirection;
  12509. private _scaledGravity;
  12510. private _currentRenderId;
  12511. private _alive;
  12512. private _useInstancing;
  12513. private _started;
  12514. private _stopped;
  12515. private _actualFrame;
  12516. private _scaledUpdateSpeed;
  12517. private _vertexBufferSize;
  12518. /** @hidden */
  12519. _currentEmitRateGradient: Nullable<FactorGradient>;
  12520. /** @hidden */
  12521. _currentEmitRate1: number;
  12522. /** @hidden */
  12523. _currentEmitRate2: number;
  12524. /** @hidden */
  12525. _currentStartSizeGradient: Nullable<FactorGradient>;
  12526. /** @hidden */
  12527. _currentStartSize1: number;
  12528. /** @hidden */
  12529. _currentStartSize2: number;
  12530. private readonly _rawTextureWidth;
  12531. private _rampGradientsTexture;
  12532. private _useRampGradients;
  12533. /** Gets or sets a boolean indicating that ramp gradients must be used
  12534. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12535. */
  12536. get useRampGradients(): boolean;
  12537. set useRampGradients(value: boolean);
  12538. /**
  12539. * 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.
  12540. * 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: [])
  12541. */
  12542. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12543. private _subEmitters;
  12544. /**
  12545. * @hidden
  12546. * If the particle systems emitter should be disposed when the particle system is disposed
  12547. */
  12548. _disposeEmitterOnDispose: boolean;
  12549. /**
  12550. * The current active Sub-systems, this property is used by the root particle system only.
  12551. */
  12552. activeSubSystems: Array<ParticleSystem>;
  12553. /**
  12554. * Specifies if the particles are updated in emitter local space or world space
  12555. */
  12556. isLocal: boolean;
  12557. private _rootParticleSystem;
  12558. /**
  12559. * Gets the current list of active particles
  12560. */
  12561. get particles(): Particle[];
  12562. /**
  12563. * Gets the number of particles active at the same time.
  12564. * @returns The number of active particles.
  12565. */
  12566. getActiveCount(): number;
  12567. /**
  12568. * Returns the string "ParticleSystem"
  12569. * @returns a string containing the class name
  12570. */
  12571. getClassName(): string;
  12572. /**
  12573. * Gets a boolean indicating that the system is stopping
  12574. * @returns true if the system is currently stopping
  12575. */
  12576. isStopping(): boolean;
  12577. /**
  12578. * Gets the custom effect used to render the particles
  12579. * @param blendMode Blend mode for which the effect should be retrieved
  12580. * @returns The effect
  12581. */
  12582. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12583. /**
  12584. * Sets the custom effect used to render the particles
  12585. * @param effect The effect to set
  12586. * @param blendMode Blend mode for which the effect should be set
  12587. */
  12588. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12589. /** @hidden */
  12590. private _onBeforeDrawParticlesObservable;
  12591. /**
  12592. * Observable that will be called just before the particles are drawn
  12593. */
  12594. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12595. /**
  12596. * Gets the name of the particle vertex shader
  12597. */
  12598. get vertexShaderName(): string;
  12599. /**
  12600. * Instantiates a particle system.
  12601. * 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.
  12602. * @param name The name of the particle system
  12603. * @param capacity The max number of particles alive at the same time
  12604. * @param scene The scene the particle system belongs to
  12605. * @param customEffect a custom effect used to change the way particles are rendered by default
  12606. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12607. * @param epsilon Offset used to render the particles
  12608. */
  12609. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12610. private _addFactorGradient;
  12611. private _removeFactorGradient;
  12612. /**
  12613. * Adds a new life time gradient
  12614. * @param gradient defines the gradient to use (between 0 and 1)
  12615. * @param factor defines the life time factor to affect to the specified gradient
  12616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12617. * @returns the current particle system
  12618. */
  12619. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12620. /**
  12621. * Remove a specific life time gradient
  12622. * @param gradient defines the gradient to remove
  12623. * @returns the current particle system
  12624. */
  12625. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12626. /**
  12627. * Adds a new size gradient
  12628. * @param gradient defines the gradient to use (between 0 and 1)
  12629. * @param factor defines the size factor to affect to the specified gradient
  12630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12631. * @returns the current particle system
  12632. */
  12633. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12634. /**
  12635. * Remove a specific size gradient
  12636. * @param gradient defines the gradient to remove
  12637. * @returns the current particle system
  12638. */
  12639. removeSizeGradient(gradient: number): IParticleSystem;
  12640. /**
  12641. * Adds a new color remap gradient
  12642. * @param gradient defines the gradient to use (between 0 and 1)
  12643. * @param min defines the color remap minimal range
  12644. * @param max defines the color remap maximal range
  12645. * @returns the current particle system
  12646. */
  12647. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12648. /**
  12649. * Remove a specific color remap gradient
  12650. * @param gradient defines the gradient to remove
  12651. * @returns the current particle system
  12652. */
  12653. removeColorRemapGradient(gradient: number): IParticleSystem;
  12654. /**
  12655. * Adds a new alpha remap gradient
  12656. * @param gradient defines the gradient to use (between 0 and 1)
  12657. * @param min defines the alpha remap minimal range
  12658. * @param max defines the alpha remap maximal range
  12659. * @returns the current particle system
  12660. */
  12661. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12662. /**
  12663. * Remove a specific alpha remap gradient
  12664. * @param gradient defines the gradient to remove
  12665. * @returns the current particle system
  12666. */
  12667. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12668. /**
  12669. * Adds a new angular speed gradient
  12670. * @param gradient defines the gradient to use (between 0 and 1)
  12671. * @param factor defines the angular speed to affect to the specified gradient
  12672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12673. * @returns the current particle system
  12674. */
  12675. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12676. /**
  12677. * Remove a specific angular speed gradient
  12678. * @param gradient defines the gradient to remove
  12679. * @returns the current particle system
  12680. */
  12681. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12682. /**
  12683. * Adds a new velocity gradient
  12684. * @param gradient defines the gradient to use (between 0 and 1)
  12685. * @param factor defines the velocity to affect to the specified gradient
  12686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12687. * @returns the current particle system
  12688. */
  12689. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12690. /**
  12691. * Remove a specific velocity gradient
  12692. * @param gradient defines the gradient to remove
  12693. * @returns the current particle system
  12694. */
  12695. removeVelocityGradient(gradient: number): IParticleSystem;
  12696. /**
  12697. * Adds a new limit velocity gradient
  12698. * @param gradient defines the gradient to use (between 0 and 1)
  12699. * @param factor defines the limit velocity value to affect to the specified gradient
  12700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12701. * @returns the current particle system
  12702. */
  12703. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12704. /**
  12705. * Remove a specific limit velocity gradient
  12706. * @param gradient defines the gradient to remove
  12707. * @returns the current particle system
  12708. */
  12709. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12710. /**
  12711. * Adds a new drag gradient
  12712. * @param gradient defines the gradient to use (between 0 and 1)
  12713. * @param factor defines the drag value to affect to the specified gradient
  12714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12715. * @returns the current particle system
  12716. */
  12717. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12718. /**
  12719. * Remove a specific drag gradient
  12720. * @param gradient defines the gradient to remove
  12721. * @returns the current particle system
  12722. */
  12723. removeDragGradient(gradient: number): IParticleSystem;
  12724. /**
  12725. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12726. * @param gradient defines the gradient to use (between 0 and 1)
  12727. * @param factor defines the emit rate value to affect to the specified gradient
  12728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12729. * @returns the current particle system
  12730. */
  12731. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12732. /**
  12733. * Remove a specific emit rate gradient
  12734. * @param gradient defines the gradient to remove
  12735. * @returns the current particle system
  12736. */
  12737. removeEmitRateGradient(gradient: number): IParticleSystem;
  12738. /**
  12739. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12740. * @param gradient defines the gradient to use (between 0 and 1)
  12741. * @param factor defines the start size value to affect to the specified gradient
  12742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12743. * @returns the current particle system
  12744. */
  12745. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12746. /**
  12747. * Remove a specific start size gradient
  12748. * @param gradient defines the gradient to remove
  12749. * @returns the current particle system
  12750. */
  12751. removeStartSizeGradient(gradient: number): IParticleSystem;
  12752. private _createRampGradientTexture;
  12753. /**
  12754. * Gets the current list of ramp gradients.
  12755. * You must use addRampGradient and removeRampGradient to udpate this list
  12756. * @returns the list of ramp gradients
  12757. */
  12758. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12759. /** Force the system to rebuild all gradients that need to be resync */
  12760. forceRefreshGradients(): void;
  12761. private _syncRampGradientTexture;
  12762. /**
  12763. * Adds a new ramp gradient used to remap particle colors
  12764. * @param gradient defines the gradient to use (between 0 and 1)
  12765. * @param color defines the color to affect to the specified gradient
  12766. * @returns the current particle system
  12767. */
  12768. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12769. /**
  12770. * Remove a specific ramp gradient
  12771. * @param gradient defines the gradient to remove
  12772. * @returns the current particle system
  12773. */
  12774. removeRampGradient(gradient: number): ParticleSystem;
  12775. /**
  12776. * Adds a new color gradient
  12777. * @param gradient defines the gradient to use (between 0 and 1)
  12778. * @param color1 defines the color to affect to the specified gradient
  12779. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12780. * @returns this particle system
  12781. */
  12782. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12783. /**
  12784. * Remove a specific color gradient
  12785. * @param gradient defines the gradient to remove
  12786. * @returns this particle system
  12787. */
  12788. removeColorGradient(gradient: number): IParticleSystem;
  12789. private _fetchR;
  12790. protected _reset(): void;
  12791. private _resetEffect;
  12792. private _createVertexBuffers;
  12793. private _createIndexBuffer;
  12794. /**
  12795. * Gets the maximum number of particles active at the same time.
  12796. * @returns The max number of active particles.
  12797. */
  12798. getCapacity(): number;
  12799. /**
  12800. * Gets whether there are still active particles in the system.
  12801. * @returns True if it is alive, otherwise false.
  12802. */
  12803. isAlive(): boolean;
  12804. /**
  12805. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12806. * @returns True if it has been started, otherwise false.
  12807. */
  12808. isStarted(): boolean;
  12809. private _prepareSubEmitterInternalArray;
  12810. /**
  12811. * Starts the particle system and begins to emit
  12812. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12813. */
  12814. start(delay?: number): void;
  12815. /**
  12816. * Stops the particle system.
  12817. * @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.
  12818. */
  12819. stop(stopSubEmitters?: boolean): void;
  12820. /**
  12821. * Remove all active particles
  12822. */
  12823. reset(): void;
  12824. /**
  12825. * @hidden (for internal use only)
  12826. */
  12827. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12828. /**
  12829. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12830. * Its lifetime will start back at 0.
  12831. */
  12832. recycleParticle: (particle: Particle) => void;
  12833. private _stopSubEmitters;
  12834. private _createParticle;
  12835. private _removeFromRoot;
  12836. private _emitFromParticle;
  12837. private _update;
  12838. /** @hidden */
  12839. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12840. /** @hidden */
  12841. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12842. /**
  12843. * Fill the defines array according to the current settings of the particle system
  12844. * @param defines Array to be updated
  12845. * @param blendMode blend mode to take into account when updating the array
  12846. */
  12847. fillDefines(defines: Array<string>, blendMode: number): void;
  12848. /**
  12849. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12850. * @param uniforms Uniforms array to fill
  12851. * @param attributes Attributes array to fill
  12852. * @param samplers Samplers array to fill
  12853. */
  12854. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12855. /** @hidden */
  12856. private _getEffect;
  12857. /**
  12858. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12859. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12860. */
  12861. animate(preWarmOnly?: boolean): void;
  12862. private _appendParticleVertices;
  12863. /**
  12864. * Rebuilds the particle system.
  12865. */
  12866. rebuild(): void;
  12867. /**
  12868. * Is this system ready to be used/rendered
  12869. * @return true if the system is ready
  12870. */
  12871. isReady(): boolean;
  12872. private _render;
  12873. /**
  12874. * Renders the particle system in its current state.
  12875. * @returns the current number of particles
  12876. */
  12877. render(): number;
  12878. /**
  12879. * Disposes the particle system and free the associated resources
  12880. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12881. */
  12882. dispose(disposeTexture?: boolean): void;
  12883. /**
  12884. * Clones the particle system.
  12885. * @param name The name of the cloned object
  12886. * @param newEmitter The new emitter to use
  12887. * @returns the cloned particle system
  12888. */
  12889. clone(name: string, newEmitter: any): ParticleSystem;
  12890. /**
  12891. * Serializes the particle system to a JSON object
  12892. * @param serializeTexture defines if the texture must be serialized as well
  12893. * @returns the JSON object
  12894. */
  12895. serialize(serializeTexture?: boolean): any;
  12896. /** @hidden */
  12897. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12898. /** @hidden */
  12899. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12900. /**
  12901. * Parses a JSON object to create a particle system.
  12902. * @param parsedParticleSystem The JSON object to parse
  12903. * @param scene The scene to create the particle system in
  12904. * @param rootUrl The root url to use to load external dependencies like texture
  12905. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12906. * @returns the Parsed particle system
  12907. */
  12908. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12909. }
  12910. }
  12911. declare module BABYLON {
  12912. /**
  12913. * A particle represents one of the element emitted by a particle system.
  12914. * This is mainly define by its coordinates, direction, velocity and age.
  12915. */
  12916. export class Particle {
  12917. /**
  12918. * The particle system the particle belongs to.
  12919. */
  12920. particleSystem: ParticleSystem;
  12921. private static _Count;
  12922. /**
  12923. * Unique ID of the particle
  12924. */
  12925. id: number;
  12926. /**
  12927. * The world position of the particle in the scene.
  12928. */
  12929. position: Vector3;
  12930. /**
  12931. * The world direction of the particle in the scene.
  12932. */
  12933. direction: Vector3;
  12934. /**
  12935. * The color of the particle.
  12936. */
  12937. color: Color4;
  12938. /**
  12939. * The color change of the particle per step.
  12940. */
  12941. colorStep: Color4;
  12942. /**
  12943. * Defines how long will the life of the particle be.
  12944. */
  12945. lifeTime: number;
  12946. /**
  12947. * The current age of the particle.
  12948. */
  12949. age: number;
  12950. /**
  12951. * The current size of the particle.
  12952. */
  12953. size: number;
  12954. /**
  12955. * The current scale of the particle.
  12956. */
  12957. scale: Vector2;
  12958. /**
  12959. * The current angle of the particle.
  12960. */
  12961. angle: number;
  12962. /**
  12963. * Defines how fast is the angle changing.
  12964. */
  12965. angularSpeed: number;
  12966. /**
  12967. * Defines the cell index used by the particle to be rendered from a sprite.
  12968. */
  12969. cellIndex: number;
  12970. /**
  12971. * The information required to support color remapping
  12972. */
  12973. remapData: Vector4;
  12974. /** @hidden */
  12975. _randomCellOffset?: number;
  12976. /** @hidden */
  12977. _initialDirection: Nullable<Vector3>;
  12978. /** @hidden */
  12979. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12980. /** @hidden */
  12981. _initialStartSpriteCellID: number;
  12982. /** @hidden */
  12983. _initialEndSpriteCellID: number;
  12984. /** @hidden */
  12985. _currentColorGradient: Nullable<ColorGradient>;
  12986. /** @hidden */
  12987. _currentColor1: Color4;
  12988. /** @hidden */
  12989. _currentColor2: Color4;
  12990. /** @hidden */
  12991. _currentSizeGradient: Nullable<FactorGradient>;
  12992. /** @hidden */
  12993. _currentSize1: number;
  12994. /** @hidden */
  12995. _currentSize2: number;
  12996. /** @hidden */
  12997. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12998. /** @hidden */
  12999. _currentAngularSpeed1: number;
  13000. /** @hidden */
  13001. _currentAngularSpeed2: number;
  13002. /** @hidden */
  13003. _currentVelocityGradient: Nullable<FactorGradient>;
  13004. /** @hidden */
  13005. _currentVelocity1: number;
  13006. /** @hidden */
  13007. _currentVelocity2: number;
  13008. /** @hidden */
  13009. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13010. /** @hidden */
  13011. _currentLimitVelocity1: number;
  13012. /** @hidden */
  13013. _currentLimitVelocity2: number;
  13014. /** @hidden */
  13015. _currentDragGradient: Nullable<FactorGradient>;
  13016. /** @hidden */
  13017. _currentDrag1: number;
  13018. /** @hidden */
  13019. _currentDrag2: number;
  13020. /** @hidden */
  13021. _randomNoiseCoordinates1: Vector3;
  13022. /** @hidden */
  13023. _randomNoiseCoordinates2: Vector3;
  13024. /** @hidden */
  13025. _localPosition?: Vector3;
  13026. /**
  13027. * Creates a new instance Particle
  13028. * @param particleSystem the particle system the particle belongs to
  13029. */
  13030. constructor(
  13031. /**
  13032. * The particle system the particle belongs to.
  13033. */
  13034. particleSystem: ParticleSystem);
  13035. private updateCellInfoFromSystem;
  13036. /**
  13037. * Defines how the sprite cell index is updated for the particle
  13038. */
  13039. updateCellIndex(): void;
  13040. /** @hidden */
  13041. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13042. /** @hidden */
  13043. _inheritParticleInfoToSubEmitters(): void;
  13044. /** @hidden */
  13045. _reset(): void;
  13046. /**
  13047. * Copy the properties of particle to another one.
  13048. * @param other the particle to copy the information to.
  13049. */
  13050. copyTo(other: Particle): void;
  13051. }
  13052. }
  13053. declare module BABYLON {
  13054. /**
  13055. * Particle emitter represents a volume emitting particles.
  13056. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13057. */
  13058. export interface IParticleEmitterType {
  13059. /**
  13060. * Called by the particle System when the direction is computed for the created particle.
  13061. * @param worldMatrix is the world matrix of the particle system
  13062. * @param directionToUpdate is the direction vector to update with the result
  13063. * @param particle is the particle we are computed the direction for
  13064. * @param isLocal defines if the direction should be set in local space
  13065. */
  13066. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13067. /**
  13068. * Called by the particle System when the position is computed for the created particle.
  13069. * @param worldMatrix is the world matrix of the particle system
  13070. * @param positionToUpdate is the position vector to update with the result
  13071. * @param particle is the particle we are computed the position for
  13072. * @param isLocal defines if the position should be set in local space
  13073. */
  13074. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13075. /**
  13076. * Clones the current emitter and returns a copy of it
  13077. * @returns the new emitter
  13078. */
  13079. clone(): IParticleEmitterType;
  13080. /**
  13081. * Called by the GPUParticleSystem to setup the update shader
  13082. * @param effect defines the update shader
  13083. */
  13084. applyToShader(effect: Effect): void;
  13085. /**
  13086. * Returns a string to use to update the GPU particles update shader
  13087. * @returns the effect defines string
  13088. */
  13089. getEffectDefines(): string;
  13090. /**
  13091. * Returns a string representing the class name
  13092. * @returns a string containing the class name
  13093. */
  13094. getClassName(): string;
  13095. /**
  13096. * Serializes the particle system to a JSON object.
  13097. * @returns the JSON object
  13098. */
  13099. serialize(): any;
  13100. /**
  13101. * Parse properties from a JSON object
  13102. * @param serializationObject defines the JSON object
  13103. * @param scene defines the hosting scene
  13104. */
  13105. parse(serializationObject: any, scene: Scene): void;
  13106. }
  13107. }
  13108. declare module BABYLON {
  13109. /**
  13110. * Particle emitter emitting particles from the inside of a box.
  13111. * It emits the particles randomly between 2 given directions.
  13112. */
  13113. export class BoxParticleEmitter implements IParticleEmitterType {
  13114. /**
  13115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13116. */
  13117. direction1: Vector3;
  13118. /**
  13119. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13120. */
  13121. direction2: Vector3;
  13122. /**
  13123. * 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.
  13124. */
  13125. minEmitBox: Vector3;
  13126. /**
  13127. * 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.
  13128. */
  13129. maxEmitBox: Vector3;
  13130. /**
  13131. * Creates a new instance BoxParticleEmitter
  13132. */
  13133. constructor();
  13134. /**
  13135. * Called by the particle System when the direction is computed for the created particle.
  13136. * @param worldMatrix is the world matrix of the particle system
  13137. * @param directionToUpdate is the direction vector to update with the result
  13138. * @param particle is the particle we are computed the direction for
  13139. * @param isLocal defines if the direction should be set in local space
  13140. */
  13141. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13142. /**
  13143. * Called by the particle System when the position is computed for the created particle.
  13144. * @param worldMatrix is the world matrix of the particle system
  13145. * @param positionToUpdate is the position vector to update with the result
  13146. * @param particle is the particle we are computed the position for
  13147. * @param isLocal defines if the position should be set in local space
  13148. */
  13149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13150. /**
  13151. * Clones the current emitter and returns a copy of it
  13152. * @returns the new emitter
  13153. */
  13154. clone(): BoxParticleEmitter;
  13155. /**
  13156. * Called by the GPUParticleSystem to setup the update shader
  13157. * @param effect defines the update shader
  13158. */
  13159. applyToShader(effect: Effect): void;
  13160. /**
  13161. * Returns a string to use to update the GPU particles update shader
  13162. * @returns a string containng the defines string
  13163. */
  13164. getEffectDefines(): string;
  13165. /**
  13166. * Returns the string "BoxParticleEmitter"
  13167. * @returns a string containing the class name
  13168. */
  13169. getClassName(): string;
  13170. /**
  13171. * Serializes the particle system to a JSON object.
  13172. * @returns the JSON object
  13173. */
  13174. serialize(): any;
  13175. /**
  13176. * Parse properties from a JSON object
  13177. * @param serializationObject defines the JSON object
  13178. */
  13179. parse(serializationObject: any): void;
  13180. }
  13181. }
  13182. declare module BABYLON {
  13183. /**
  13184. * Particle emitter emitting particles from the inside of a cone.
  13185. * It emits the particles alongside the cone volume from the base to the particle.
  13186. * The emission direction might be randomized.
  13187. */
  13188. export class ConeParticleEmitter implements IParticleEmitterType {
  13189. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13190. directionRandomizer: number;
  13191. private _radius;
  13192. private _angle;
  13193. private _height;
  13194. /**
  13195. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13196. */
  13197. radiusRange: number;
  13198. /**
  13199. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13200. */
  13201. heightRange: number;
  13202. /**
  13203. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13204. */
  13205. emitFromSpawnPointOnly: boolean;
  13206. /**
  13207. * Gets or sets the radius of the emission cone
  13208. */
  13209. get radius(): number;
  13210. set radius(value: number);
  13211. /**
  13212. * Gets or sets the angle of the emission cone
  13213. */
  13214. get angle(): number;
  13215. set angle(value: number);
  13216. private _buildHeight;
  13217. /**
  13218. * Creates a new instance ConeParticleEmitter
  13219. * @param radius the radius of the emission cone (1 by default)
  13220. * @param angle the cone base angle (PI by default)
  13221. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13222. */
  13223. constructor(radius?: number, angle?: number,
  13224. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13225. directionRandomizer?: number);
  13226. /**
  13227. * Called by the particle System when the direction is computed for the created particle.
  13228. * @param worldMatrix is the world matrix of the particle system
  13229. * @param directionToUpdate is the direction vector to update with the result
  13230. * @param particle is the particle we are computed the direction for
  13231. * @param isLocal defines if the direction should be set in local space
  13232. */
  13233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13234. /**
  13235. * Called by the particle System when the position is computed for the created particle.
  13236. * @param worldMatrix is the world matrix of the particle system
  13237. * @param positionToUpdate is the position vector to update with the result
  13238. * @param particle is the particle we are computed the position for
  13239. * @param isLocal defines if the position should be set in local space
  13240. */
  13241. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13242. /**
  13243. * Clones the current emitter and returns a copy of it
  13244. * @returns the new emitter
  13245. */
  13246. clone(): ConeParticleEmitter;
  13247. /**
  13248. * Called by the GPUParticleSystem to setup the update shader
  13249. * @param effect defines the update shader
  13250. */
  13251. applyToShader(effect: Effect): void;
  13252. /**
  13253. * Returns a string to use to update the GPU particles update shader
  13254. * @returns a string containng the defines string
  13255. */
  13256. getEffectDefines(): string;
  13257. /**
  13258. * Returns the string "ConeParticleEmitter"
  13259. * @returns a string containing the class name
  13260. */
  13261. getClassName(): string;
  13262. /**
  13263. * Serializes the particle system to a JSON object.
  13264. * @returns the JSON object
  13265. */
  13266. serialize(): any;
  13267. /**
  13268. * Parse properties from a JSON object
  13269. * @param serializationObject defines the JSON object
  13270. */
  13271. parse(serializationObject: any): void;
  13272. }
  13273. }
  13274. declare module BABYLON {
  13275. /**
  13276. * Particle emitter emitting particles from the inside of a cylinder.
  13277. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13278. */
  13279. export class CylinderParticleEmitter implements IParticleEmitterType {
  13280. /**
  13281. * The radius of the emission cylinder.
  13282. */
  13283. radius: number;
  13284. /**
  13285. * The height of the emission cylinder.
  13286. */
  13287. height: number;
  13288. /**
  13289. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13290. */
  13291. radiusRange: number;
  13292. /**
  13293. * How much to randomize the particle direction [0-1].
  13294. */
  13295. directionRandomizer: number;
  13296. /**
  13297. * Creates a new instance CylinderParticleEmitter
  13298. * @param radius the radius of the emission cylinder (1 by default)
  13299. * @param height the height of the emission cylinder (1 by default)
  13300. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13301. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13302. */
  13303. constructor(
  13304. /**
  13305. * The radius of the emission cylinder.
  13306. */
  13307. radius?: number,
  13308. /**
  13309. * The height of the emission cylinder.
  13310. */
  13311. height?: number,
  13312. /**
  13313. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13314. */
  13315. radiusRange?: number,
  13316. /**
  13317. * How much to randomize the particle direction [0-1].
  13318. */
  13319. directionRandomizer?: number);
  13320. /**
  13321. * Called by the particle System when the direction is computed for the created particle.
  13322. * @param worldMatrix is the world matrix of the particle system
  13323. * @param directionToUpdate is the direction vector to update with the result
  13324. * @param particle is the particle we are computed the direction for
  13325. * @param isLocal defines if the direction should be set in local space
  13326. */
  13327. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13328. /**
  13329. * Called by the particle System when the position is computed for the created particle.
  13330. * @param worldMatrix is the world matrix of the particle system
  13331. * @param positionToUpdate is the position vector to update with the result
  13332. * @param particle is the particle we are computed the position for
  13333. * @param isLocal defines if the position should be set in local space
  13334. */
  13335. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13336. /**
  13337. * Clones the current emitter and returns a copy of it
  13338. * @returns the new emitter
  13339. */
  13340. clone(): CylinderParticleEmitter;
  13341. /**
  13342. * Called by the GPUParticleSystem to setup the update shader
  13343. * @param effect defines the update shader
  13344. */
  13345. applyToShader(effect: Effect): void;
  13346. /**
  13347. * Returns a string to use to update the GPU particles update shader
  13348. * @returns a string containng the defines string
  13349. */
  13350. getEffectDefines(): string;
  13351. /**
  13352. * Returns the string "CylinderParticleEmitter"
  13353. * @returns a string containing the class name
  13354. */
  13355. getClassName(): string;
  13356. /**
  13357. * Serializes the particle system to a JSON object.
  13358. * @returns the JSON object
  13359. */
  13360. serialize(): any;
  13361. /**
  13362. * Parse properties from a JSON object
  13363. * @param serializationObject defines the JSON object
  13364. */
  13365. parse(serializationObject: any): void;
  13366. }
  13367. /**
  13368. * Particle emitter emitting particles from the inside of a cylinder.
  13369. * It emits the particles randomly between two vectors.
  13370. */
  13371. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13372. /**
  13373. * The min limit of the emission direction.
  13374. */
  13375. direction1: Vector3;
  13376. /**
  13377. * The max limit of the emission direction.
  13378. */
  13379. direction2: Vector3;
  13380. /**
  13381. * Creates a new instance CylinderDirectedParticleEmitter
  13382. * @param radius the radius of the emission cylinder (1 by default)
  13383. * @param height the height of the emission cylinder (1 by default)
  13384. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13385. * @param direction1 the min limit of the emission direction (up vector by default)
  13386. * @param direction2 the max limit of the emission direction (up vector by default)
  13387. */
  13388. constructor(radius?: number, height?: number, radiusRange?: number,
  13389. /**
  13390. * The min limit of the emission direction.
  13391. */
  13392. direction1?: Vector3,
  13393. /**
  13394. * The max limit of the emission direction.
  13395. */
  13396. direction2?: Vector3);
  13397. /**
  13398. * Called by the particle System when the direction is computed for the created particle.
  13399. * @param worldMatrix is the world matrix of the particle system
  13400. * @param directionToUpdate is the direction vector to update with the result
  13401. * @param particle is the particle we are computed the direction for
  13402. */
  13403. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13404. /**
  13405. * Clones the current emitter and returns a copy of it
  13406. * @returns the new emitter
  13407. */
  13408. clone(): CylinderDirectedParticleEmitter;
  13409. /**
  13410. * Called by the GPUParticleSystem to setup the update shader
  13411. * @param effect defines the update shader
  13412. */
  13413. applyToShader(effect: Effect): void;
  13414. /**
  13415. * Returns a string to use to update the GPU particles update shader
  13416. * @returns a string containng the defines string
  13417. */
  13418. getEffectDefines(): string;
  13419. /**
  13420. * Returns the string "CylinderDirectedParticleEmitter"
  13421. * @returns a string containing the class name
  13422. */
  13423. getClassName(): string;
  13424. /**
  13425. * Serializes the particle system to a JSON object.
  13426. * @returns the JSON object
  13427. */
  13428. serialize(): any;
  13429. /**
  13430. * Parse properties from a JSON object
  13431. * @param serializationObject defines the JSON object
  13432. */
  13433. parse(serializationObject: any): void;
  13434. }
  13435. }
  13436. declare module BABYLON {
  13437. /**
  13438. * Particle emitter emitting particles from the inside of a hemisphere.
  13439. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13440. */
  13441. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13442. /**
  13443. * The radius of the emission hemisphere.
  13444. */
  13445. radius: number;
  13446. /**
  13447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13448. */
  13449. radiusRange: number;
  13450. /**
  13451. * How much to randomize the particle direction [0-1].
  13452. */
  13453. directionRandomizer: number;
  13454. /**
  13455. * Creates a new instance HemisphericParticleEmitter
  13456. * @param radius the radius of the emission hemisphere (1 by default)
  13457. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13458. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13459. */
  13460. constructor(
  13461. /**
  13462. * The radius of the emission hemisphere.
  13463. */
  13464. radius?: number,
  13465. /**
  13466. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13467. */
  13468. radiusRange?: number,
  13469. /**
  13470. * How much to randomize the particle direction [0-1].
  13471. */
  13472. directionRandomizer?: number);
  13473. /**
  13474. * Called by the particle System when the direction is computed for the created particle.
  13475. * @param worldMatrix is the world matrix of the particle system
  13476. * @param directionToUpdate is the direction vector to update with the result
  13477. * @param particle is the particle we are computed the direction for
  13478. * @param isLocal defines if the direction should be set in local space
  13479. */
  13480. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13481. /**
  13482. * Called by the particle System when the position is computed for the created particle.
  13483. * @param worldMatrix is the world matrix of the particle system
  13484. * @param positionToUpdate is the position vector to update with the result
  13485. * @param particle is the particle we are computed the position for
  13486. * @param isLocal defines if the position should be set in local space
  13487. */
  13488. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13489. /**
  13490. * Clones the current emitter and returns a copy of it
  13491. * @returns the new emitter
  13492. */
  13493. clone(): HemisphericParticleEmitter;
  13494. /**
  13495. * Called by the GPUParticleSystem to setup the update shader
  13496. * @param effect defines the update shader
  13497. */
  13498. applyToShader(effect: Effect): void;
  13499. /**
  13500. * Returns a string to use to update the GPU particles update shader
  13501. * @returns a string containng the defines string
  13502. */
  13503. getEffectDefines(): string;
  13504. /**
  13505. * Returns the string "HemisphericParticleEmitter"
  13506. * @returns a string containing the class name
  13507. */
  13508. getClassName(): string;
  13509. /**
  13510. * Serializes the particle system to a JSON object.
  13511. * @returns the JSON object
  13512. */
  13513. serialize(): any;
  13514. /**
  13515. * Parse properties from a JSON object
  13516. * @param serializationObject defines the JSON object
  13517. */
  13518. parse(serializationObject: any): void;
  13519. }
  13520. }
  13521. declare module BABYLON {
  13522. /**
  13523. * Particle emitter emitting particles from a point.
  13524. * It emits the particles randomly between 2 given directions.
  13525. */
  13526. export class PointParticleEmitter implements IParticleEmitterType {
  13527. /**
  13528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13529. */
  13530. direction1: Vector3;
  13531. /**
  13532. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13533. */
  13534. direction2: Vector3;
  13535. /**
  13536. * Creates a new instance PointParticleEmitter
  13537. */
  13538. constructor();
  13539. /**
  13540. * Called by the particle System when the direction is computed for the created particle.
  13541. * @param worldMatrix is the world matrix of the particle system
  13542. * @param directionToUpdate is the direction vector to update with the result
  13543. * @param particle is the particle we are computed the direction for
  13544. * @param isLocal defines if the direction should be set in local space
  13545. */
  13546. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13547. /**
  13548. * Called by the particle System when the position is computed for the created particle.
  13549. * @param worldMatrix is the world matrix of the particle system
  13550. * @param positionToUpdate is the position vector to update with the result
  13551. * @param particle is the particle we are computed the position for
  13552. * @param isLocal defines if the position should be set in local space
  13553. */
  13554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13555. /**
  13556. * Clones the current emitter and returns a copy of it
  13557. * @returns the new emitter
  13558. */
  13559. clone(): PointParticleEmitter;
  13560. /**
  13561. * Called by the GPUParticleSystem to setup the update shader
  13562. * @param effect defines the update shader
  13563. */
  13564. applyToShader(effect: Effect): void;
  13565. /**
  13566. * Returns a string to use to update the GPU particles update shader
  13567. * @returns a string containng the defines string
  13568. */
  13569. getEffectDefines(): string;
  13570. /**
  13571. * Returns the string "PointParticleEmitter"
  13572. * @returns a string containing the class name
  13573. */
  13574. getClassName(): string;
  13575. /**
  13576. * Serializes the particle system to a JSON object.
  13577. * @returns the JSON object
  13578. */
  13579. serialize(): any;
  13580. /**
  13581. * Parse properties from a JSON object
  13582. * @param serializationObject defines the JSON object
  13583. */
  13584. parse(serializationObject: any): void;
  13585. }
  13586. }
  13587. declare module BABYLON {
  13588. /**
  13589. * Particle emitter emitting particles from the inside of a sphere.
  13590. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13591. */
  13592. export class SphereParticleEmitter implements IParticleEmitterType {
  13593. /**
  13594. * The radius of the emission sphere.
  13595. */
  13596. radius: number;
  13597. /**
  13598. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13599. */
  13600. radiusRange: number;
  13601. /**
  13602. * How much to randomize the particle direction [0-1].
  13603. */
  13604. directionRandomizer: number;
  13605. /**
  13606. * Creates a new instance SphereParticleEmitter
  13607. * @param radius the radius of the emission sphere (1 by default)
  13608. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13609. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13610. */
  13611. constructor(
  13612. /**
  13613. * The radius of the emission sphere.
  13614. */
  13615. radius?: number,
  13616. /**
  13617. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13618. */
  13619. radiusRange?: number,
  13620. /**
  13621. * How much to randomize the particle direction [0-1].
  13622. */
  13623. directionRandomizer?: number);
  13624. /**
  13625. * Called by the particle System when the direction is computed for the created particle.
  13626. * @param worldMatrix is the world matrix of the particle system
  13627. * @param directionToUpdate is the direction vector to update with the result
  13628. * @param particle is the particle we are computed the direction for
  13629. * @param isLocal defines if the direction should be set in local space
  13630. */
  13631. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13632. /**
  13633. * Called by the particle System when the position is computed for the created particle.
  13634. * @param worldMatrix is the world matrix of the particle system
  13635. * @param positionToUpdate is the position vector to update with the result
  13636. * @param particle is the particle we are computed the position for
  13637. * @param isLocal defines if the position should be set in local space
  13638. */
  13639. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13640. /**
  13641. * Clones the current emitter and returns a copy of it
  13642. * @returns the new emitter
  13643. */
  13644. clone(): SphereParticleEmitter;
  13645. /**
  13646. * Called by the GPUParticleSystem to setup the update shader
  13647. * @param effect defines the update shader
  13648. */
  13649. applyToShader(effect: Effect): void;
  13650. /**
  13651. * Returns a string to use to update the GPU particles update shader
  13652. * @returns a string containng the defines string
  13653. */
  13654. getEffectDefines(): string;
  13655. /**
  13656. * Returns the string "SphereParticleEmitter"
  13657. * @returns a string containing the class name
  13658. */
  13659. getClassName(): string;
  13660. /**
  13661. * Serializes the particle system to a JSON object.
  13662. * @returns the JSON object
  13663. */
  13664. serialize(): any;
  13665. /**
  13666. * Parse properties from a JSON object
  13667. * @param serializationObject defines the JSON object
  13668. */
  13669. parse(serializationObject: any): void;
  13670. }
  13671. /**
  13672. * Particle emitter emitting particles from the inside of a sphere.
  13673. * It emits the particles randomly between two vectors.
  13674. */
  13675. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13676. /**
  13677. * The min limit of the emission direction.
  13678. */
  13679. direction1: Vector3;
  13680. /**
  13681. * The max limit of the emission direction.
  13682. */
  13683. direction2: Vector3;
  13684. /**
  13685. * Creates a new instance SphereDirectedParticleEmitter
  13686. * @param radius the radius of the emission sphere (1 by default)
  13687. * @param direction1 the min limit of the emission direction (up vector by default)
  13688. * @param direction2 the max limit of the emission direction (up vector by default)
  13689. */
  13690. constructor(radius?: number,
  13691. /**
  13692. * The min limit of the emission direction.
  13693. */
  13694. direction1?: Vector3,
  13695. /**
  13696. * The max limit of the emission direction.
  13697. */
  13698. direction2?: Vector3);
  13699. /**
  13700. * Called by the particle System when the direction is computed for the created particle.
  13701. * @param worldMatrix is the world matrix of the particle system
  13702. * @param directionToUpdate is the direction vector to update with the result
  13703. * @param particle is the particle we are computed the direction for
  13704. */
  13705. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13706. /**
  13707. * Clones the current emitter and returns a copy of it
  13708. * @returns the new emitter
  13709. */
  13710. clone(): SphereDirectedParticleEmitter;
  13711. /**
  13712. * Called by the GPUParticleSystem to setup the update shader
  13713. * @param effect defines the update shader
  13714. */
  13715. applyToShader(effect: Effect): void;
  13716. /**
  13717. * Returns a string to use to update the GPU particles update shader
  13718. * @returns a string containng the defines string
  13719. */
  13720. getEffectDefines(): string;
  13721. /**
  13722. * Returns the string "SphereDirectedParticleEmitter"
  13723. * @returns a string containing the class name
  13724. */
  13725. getClassName(): string;
  13726. /**
  13727. * Serializes the particle system to a JSON object.
  13728. * @returns the JSON object
  13729. */
  13730. serialize(): any;
  13731. /**
  13732. * Parse properties from a JSON object
  13733. * @param serializationObject defines the JSON object
  13734. */
  13735. parse(serializationObject: any): void;
  13736. }
  13737. }
  13738. declare module BABYLON {
  13739. /**
  13740. * Particle emitter emitting particles from a custom list of positions.
  13741. */
  13742. export class CustomParticleEmitter implements IParticleEmitterType {
  13743. /**
  13744. * Gets or sets the position generator that will create the inital position of each particle.
  13745. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13746. */
  13747. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13748. /**
  13749. * Gets or sets the destination generator that will create the final destination of each particle.
  13750. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13751. */
  13752. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13753. /**
  13754. * Creates a new instance CustomParticleEmitter
  13755. */
  13756. constructor();
  13757. /**
  13758. * Called by the particle System when the direction is computed for the created particle.
  13759. * @param worldMatrix is the world matrix of the particle system
  13760. * @param directionToUpdate is the direction vector to update with the result
  13761. * @param particle is the particle we are computed the direction for
  13762. * @param isLocal defines if the direction should be set in local space
  13763. */
  13764. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13765. /**
  13766. * Called by the particle System when the position is computed for the created particle.
  13767. * @param worldMatrix is the world matrix of the particle system
  13768. * @param positionToUpdate is the position vector to update with the result
  13769. * @param particle is the particle we are computed the position for
  13770. * @param isLocal defines if the position should be set in local space
  13771. */
  13772. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13773. /**
  13774. * Clones the current emitter and returns a copy of it
  13775. * @returns the new emitter
  13776. */
  13777. clone(): CustomParticleEmitter;
  13778. /**
  13779. * Called by the GPUParticleSystem to setup the update shader
  13780. * @param effect defines the update shader
  13781. */
  13782. applyToShader(effect: Effect): void;
  13783. /**
  13784. * Returns a string to use to update the GPU particles update shader
  13785. * @returns a string containng the defines string
  13786. */
  13787. getEffectDefines(): string;
  13788. /**
  13789. * Returns the string "PointParticleEmitter"
  13790. * @returns a string containing the class name
  13791. */
  13792. getClassName(): string;
  13793. /**
  13794. * Serializes the particle system to a JSON object.
  13795. * @returns the JSON object
  13796. */
  13797. serialize(): any;
  13798. /**
  13799. * Parse properties from a JSON object
  13800. * @param serializationObject defines the JSON object
  13801. */
  13802. parse(serializationObject: any): void;
  13803. }
  13804. }
  13805. declare module BABYLON {
  13806. /**
  13807. * Particle emitter emitting particles from the inside of a box.
  13808. * It emits the particles randomly between 2 given directions.
  13809. */
  13810. export class MeshParticleEmitter implements IParticleEmitterType {
  13811. private _indices;
  13812. private _positions;
  13813. private _normals;
  13814. private _storedNormal;
  13815. private _mesh;
  13816. /**
  13817. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13818. */
  13819. direction1: Vector3;
  13820. /**
  13821. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13822. */
  13823. direction2: Vector3;
  13824. /**
  13825. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13826. */
  13827. useMeshNormalsForDirection: boolean;
  13828. /** Defines the mesh to use as source */
  13829. get mesh(): Nullable<AbstractMesh>;
  13830. set mesh(value: Nullable<AbstractMesh>);
  13831. /**
  13832. * Creates a new instance MeshParticleEmitter
  13833. * @param mesh defines the mesh to use as source
  13834. */
  13835. constructor(mesh?: Nullable<AbstractMesh>);
  13836. /**
  13837. * Called by the particle System when the direction is computed for the created particle.
  13838. * @param worldMatrix is the world matrix of the particle system
  13839. * @param directionToUpdate is the direction vector to update with the result
  13840. * @param particle is the particle we are computed the direction for
  13841. * @param isLocal defines if the direction should be set in local space
  13842. */
  13843. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13844. /**
  13845. * Called by the particle System when the position is computed for the created particle.
  13846. * @param worldMatrix is the world matrix of the particle system
  13847. * @param positionToUpdate is the position vector to update with the result
  13848. * @param particle is the particle we are computed the position for
  13849. * @param isLocal defines if the position should be set in local space
  13850. */
  13851. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13852. /**
  13853. * Clones the current emitter and returns a copy of it
  13854. * @returns the new emitter
  13855. */
  13856. clone(): MeshParticleEmitter;
  13857. /**
  13858. * Called by the GPUParticleSystem to setup the update shader
  13859. * @param effect defines the update shader
  13860. */
  13861. applyToShader(effect: Effect): void;
  13862. /**
  13863. * Returns a string to use to update the GPU particles update shader
  13864. * @returns a string containng the defines string
  13865. */
  13866. getEffectDefines(): string;
  13867. /**
  13868. * Returns the string "BoxParticleEmitter"
  13869. * @returns a string containing the class name
  13870. */
  13871. getClassName(): string;
  13872. /**
  13873. * Serializes the particle system to a JSON object.
  13874. * @returns the JSON object
  13875. */
  13876. serialize(): any;
  13877. /**
  13878. * Parse properties from a JSON object
  13879. * @param serializationObject defines the JSON object
  13880. * @param scene defines the hosting scene
  13881. */
  13882. parse(serializationObject: any, scene: Scene): void;
  13883. }
  13884. }
  13885. declare module BABYLON {
  13886. /**
  13887. * Interface representing a particle system in Babylon.js.
  13888. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13889. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13890. */
  13891. export interface IParticleSystem {
  13892. /**
  13893. * List of animations used by the particle system.
  13894. */
  13895. animations: Animation[];
  13896. /**
  13897. * The id of the Particle system.
  13898. */
  13899. id: string;
  13900. /**
  13901. * The name of the Particle system.
  13902. */
  13903. name: string;
  13904. /**
  13905. * The emitter represents the Mesh or position we are attaching the particle system to.
  13906. */
  13907. emitter: Nullable<AbstractMesh | Vector3>;
  13908. /**
  13909. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13910. */
  13911. isBillboardBased: boolean;
  13912. /**
  13913. * The rendering group used by the Particle system to chose when to render.
  13914. */
  13915. renderingGroupId: number;
  13916. /**
  13917. * The layer mask we are rendering the particles through.
  13918. */
  13919. layerMask: number;
  13920. /**
  13921. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13922. */
  13923. updateSpeed: number;
  13924. /**
  13925. * The amount of time the particle system is running (depends of the overall update speed).
  13926. */
  13927. targetStopDuration: number;
  13928. /**
  13929. * The texture used to render each particle. (this can be a spritesheet)
  13930. */
  13931. particleTexture: Nullable<Texture>;
  13932. /**
  13933. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13934. */
  13935. blendMode: number;
  13936. /**
  13937. * Minimum life time of emitting particles.
  13938. */
  13939. minLifeTime: number;
  13940. /**
  13941. * Maximum life time of emitting particles.
  13942. */
  13943. maxLifeTime: number;
  13944. /**
  13945. * Minimum Size of emitting particles.
  13946. */
  13947. minSize: number;
  13948. /**
  13949. * Maximum Size of emitting particles.
  13950. */
  13951. maxSize: number;
  13952. /**
  13953. * Minimum scale of emitting particles on X axis.
  13954. */
  13955. minScaleX: number;
  13956. /**
  13957. * Maximum scale of emitting particles on X axis.
  13958. */
  13959. maxScaleX: number;
  13960. /**
  13961. * Minimum scale of emitting particles on Y axis.
  13962. */
  13963. minScaleY: number;
  13964. /**
  13965. * Maximum scale of emitting particles on Y axis.
  13966. */
  13967. maxScaleY: number;
  13968. /**
  13969. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13970. */
  13971. color1: Color4;
  13972. /**
  13973. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13974. */
  13975. color2: Color4;
  13976. /**
  13977. * Color the particle will have at the end of its lifetime.
  13978. */
  13979. colorDead: Color4;
  13980. /**
  13981. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13982. */
  13983. emitRate: number;
  13984. /**
  13985. * You can use gravity if you want to give an orientation to your particles.
  13986. */
  13987. gravity: Vector3;
  13988. /**
  13989. * Minimum power of emitting particles.
  13990. */
  13991. minEmitPower: number;
  13992. /**
  13993. * Maximum power of emitting particles.
  13994. */
  13995. maxEmitPower: number;
  13996. /**
  13997. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13998. */
  13999. minAngularSpeed: number;
  14000. /**
  14001. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14002. */
  14003. maxAngularSpeed: number;
  14004. /**
  14005. * Gets or sets the minimal initial rotation in radians.
  14006. */
  14007. minInitialRotation: number;
  14008. /**
  14009. * Gets or sets the maximal initial rotation in radians.
  14010. */
  14011. maxInitialRotation: number;
  14012. /**
  14013. * The particle emitter type defines the emitter used by the particle system.
  14014. * It can be for example box, sphere, or cone...
  14015. */
  14016. particleEmitterType: Nullable<IParticleEmitterType>;
  14017. /**
  14018. * Defines the delay in milliseconds before starting the system (0 by default)
  14019. */
  14020. startDelay: number;
  14021. /**
  14022. * 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
  14023. */
  14024. preWarmCycles: number;
  14025. /**
  14026. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14027. */
  14028. preWarmStepOffset: number;
  14029. /**
  14030. * 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)
  14031. */
  14032. spriteCellChangeSpeed: number;
  14033. /**
  14034. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14035. */
  14036. startSpriteCellID: number;
  14037. /**
  14038. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14039. */
  14040. endSpriteCellID: number;
  14041. /**
  14042. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14043. */
  14044. spriteCellWidth: number;
  14045. /**
  14046. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14047. */
  14048. spriteCellHeight: number;
  14049. /**
  14050. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14051. */
  14052. spriteRandomStartCell: boolean;
  14053. /**
  14054. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14055. */
  14056. isAnimationSheetEnabled: boolean;
  14057. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14058. translationPivot: Vector2;
  14059. /**
  14060. * Gets or sets a texture used to add random noise to particle positions
  14061. */
  14062. noiseTexture: Nullable<BaseTexture>;
  14063. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14064. noiseStrength: Vector3;
  14065. /**
  14066. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14067. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14068. */
  14069. billboardMode: number;
  14070. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14071. limitVelocityDamping: number;
  14072. /**
  14073. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14074. */
  14075. beginAnimationOnStart: boolean;
  14076. /**
  14077. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14078. */
  14079. beginAnimationFrom: number;
  14080. /**
  14081. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14082. */
  14083. beginAnimationTo: number;
  14084. /**
  14085. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14086. */
  14087. beginAnimationLoop: boolean;
  14088. /**
  14089. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14090. */
  14091. disposeOnStop: boolean;
  14092. /**
  14093. * Specifies if the particles are updated in emitter local space or world space
  14094. */
  14095. isLocal: boolean;
  14096. /** Snippet ID if the particle system was created from the snippet server */
  14097. snippetId: string;
  14098. /**
  14099. * Gets the maximum number of particles active at the same time.
  14100. * @returns The max number of active particles.
  14101. */
  14102. getCapacity(): number;
  14103. /**
  14104. * Gets the number of particles active at the same time.
  14105. * @returns The number of active particles.
  14106. */
  14107. getActiveCount(): number;
  14108. /**
  14109. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14110. * @returns True if it has been started, otherwise false.
  14111. */
  14112. isStarted(): boolean;
  14113. /**
  14114. * Animates the particle system for this frame.
  14115. */
  14116. animate(): void;
  14117. /**
  14118. * Renders the particle system in its current state.
  14119. * @returns the current number of particles
  14120. */
  14121. render(): number;
  14122. /**
  14123. * Dispose the particle system and frees its associated resources.
  14124. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14125. */
  14126. dispose(disposeTexture?: boolean): void;
  14127. /**
  14128. * An event triggered when the system is disposed
  14129. */
  14130. onDisposeObservable: Observable<IParticleSystem>;
  14131. /**
  14132. * Clones the particle system.
  14133. * @param name The name of the cloned object
  14134. * @param newEmitter The new emitter to use
  14135. * @returns the cloned particle system
  14136. */
  14137. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14138. /**
  14139. * Serializes the particle system to a JSON object
  14140. * @param serializeTexture defines if the texture must be serialized as well
  14141. * @returns the JSON object
  14142. */
  14143. serialize(serializeTexture: boolean): any;
  14144. /**
  14145. * Rebuild the particle system
  14146. */
  14147. rebuild(): void;
  14148. /** Force the system to rebuild all gradients that need to be resync */
  14149. forceRefreshGradients(): void;
  14150. /**
  14151. * Starts the particle system and begins to emit
  14152. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14153. */
  14154. start(delay?: number): void;
  14155. /**
  14156. * Stops the particle system.
  14157. */
  14158. stop(): void;
  14159. /**
  14160. * Remove all active particles
  14161. */
  14162. reset(): void;
  14163. /**
  14164. * Gets a boolean indicating that the system is stopping
  14165. * @returns true if the system is currently stopping
  14166. */
  14167. isStopping(): boolean;
  14168. /**
  14169. * Is this system ready to be used/rendered
  14170. * @return true if the system is ready
  14171. */
  14172. isReady(): boolean;
  14173. /**
  14174. * Returns the string "ParticleSystem"
  14175. * @returns a string containing the class name
  14176. */
  14177. getClassName(): string;
  14178. /**
  14179. * Gets the custom effect used to render the particles
  14180. * @param blendMode Blend mode for which the effect should be retrieved
  14181. * @returns The effect
  14182. */
  14183. getCustomEffect(blendMode: number): Nullable<Effect>;
  14184. /**
  14185. * Sets the custom effect used to render the particles
  14186. * @param effect The effect to set
  14187. * @param blendMode Blend mode for which the effect should be set
  14188. */
  14189. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14190. /**
  14191. * Fill the defines array according to the current settings of the particle system
  14192. * @param defines Array to be updated
  14193. * @param blendMode blend mode to take into account when updating the array
  14194. */
  14195. fillDefines(defines: Array<string>, blendMode: number): void;
  14196. /**
  14197. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14198. * @param uniforms Uniforms array to fill
  14199. * @param attributes Attributes array to fill
  14200. * @param samplers Samplers array to fill
  14201. */
  14202. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14203. /**
  14204. * Observable that will be called just before the particles are drawn
  14205. */
  14206. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14207. /**
  14208. * Gets the name of the particle vertex shader
  14209. */
  14210. vertexShaderName: string;
  14211. /**
  14212. * Adds a new color gradient
  14213. * @param gradient defines the gradient to use (between 0 and 1)
  14214. * @param color1 defines the color to affect to the specified gradient
  14215. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14216. * @returns the current particle system
  14217. */
  14218. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14219. /**
  14220. * Remove a specific color gradient
  14221. * @param gradient defines the gradient to remove
  14222. * @returns the current particle system
  14223. */
  14224. removeColorGradient(gradient: number): IParticleSystem;
  14225. /**
  14226. * Adds a new size gradient
  14227. * @param gradient defines the gradient to use (between 0 and 1)
  14228. * @param factor defines the size factor to affect to the specified gradient
  14229. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14230. * @returns the current particle system
  14231. */
  14232. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14233. /**
  14234. * Remove a specific size gradient
  14235. * @param gradient defines the gradient to remove
  14236. * @returns the current particle system
  14237. */
  14238. removeSizeGradient(gradient: number): IParticleSystem;
  14239. /**
  14240. * Gets the current list of color gradients.
  14241. * You must use addColorGradient and removeColorGradient to udpate this list
  14242. * @returns the list of color gradients
  14243. */
  14244. getColorGradients(): Nullable<Array<ColorGradient>>;
  14245. /**
  14246. * Gets the current list of size gradients.
  14247. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14248. * @returns the list of size gradients
  14249. */
  14250. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14251. /**
  14252. * Gets the current list of angular speed gradients.
  14253. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14254. * @returns the list of angular speed gradients
  14255. */
  14256. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14257. /**
  14258. * Adds a new angular speed gradient
  14259. * @param gradient defines the gradient to use (between 0 and 1)
  14260. * @param factor defines the angular speed to affect to the specified gradient
  14261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14262. * @returns the current particle system
  14263. */
  14264. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14265. /**
  14266. * Remove a specific angular speed gradient
  14267. * @param gradient defines the gradient to remove
  14268. * @returns the current particle system
  14269. */
  14270. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14271. /**
  14272. * Gets the current list of velocity gradients.
  14273. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14274. * @returns the list of velocity gradients
  14275. */
  14276. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14277. /**
  14278. * Adds a new velocity gradient
  14279. * @param gradient defines the gradient to use (between 0 and 1)
  14280. * @param factor defines the velocity to affect to the specified gradient
  14281. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14282. * @returns the current particle system
  14283. */
  14284. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14285. /**
  14286. * Remove a specific velocity gradient
  14287. * @param gradient defines the gradient to remove
  14288. * @returns the current particle system
  14289. */
  14290. removeVelocityGradient(gradient: number): IParticleSystem;
  14291. /**
  14292. * Gets the current list of limit velocity gradients.
  14293. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14294. * @returns the list of limit velocity gradients
  14295. */
  14296. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14297. /**
  14298. * Adds a new limit velocity gradient
  14299. * @param gradient defines the gradient to use (between 0 and 1)
  14300. * @param factor defines the limit velocity to affect to the specified gradient
  14301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14302. * @returns the current particle system
  14303. */
  14304. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14305. /**
  14306. * Remove a specific limit velocity gradient
  14307. * @param gradient defines the gradient to remove
  14308. * @returns the current particle system
  14309. */
  14310. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14311. /**
  14312. * Adds a new drag gradient
  14313. * @param gradient defines the gradient to use (between 0 and 1)
  14314. * @param factor defines the drag to affect to the specified gradient
  14315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14316. * @returns the current particle system
  14317. */
  14318. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14319. /**
  14320. * Remove a specific drag gradient
  14321. * @param gradient defines the gradient to remove
  14322. * @returns the current particle system
  14323. */
  14324. removeDragGradient(gradient: number): IParticleSystem;
  14325. /**
  14326. * Gets the current list of drag gradients.
  14327. * You must use addDragGradient and removeDragGradient to udpate this list
  14328. * @returns the list of drag gradients
  14329. */
  14330. getDragGradients(): Nullable<Array<FactorGradient>>;
  14331. /**
  14332. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14333. * @param gradient defines the gradient to use (between 0 and 1)
  14334. * @param factor defines the emit rate to affect to the specified gradient
  14335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14336. * @returns the current particle system
  14337. */
  14338. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14339. /**
  14340. * Remove a specific emit rate gradient
  14341. * @param gradient defines the gradient to remove
  14342. * @returns the current particle system
  14343. */
  14344. removeEmitRateGradient(gradient: number): IParticleSystem;
  14345. /**
  14346. * Gets the current list of emit rate gradients.
  14347. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14348. * @returns the list of emit rate gradients
  14349. */
  14350. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14351. /**
  14352. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14353. * @param gradient defines the gradient to use (between 0 and 1)
  14354. * @param factor defines the start size to affect to the specified gradient
  14355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14356. * @returns the current particle system
  14357. */
  14358. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14359. /**
  14360. * Remove a specific start size gradient
  14361. * @param gradient defines the gradient to remove
  14362. * @returns the current particle system
  14363. */
  14364. removeStartSizeGradient(gradient: number): IParticleSystem;
  14365. /**
  14366. * Gets the current list of start size gradients.
  14367. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14368. * @returns the list of start size gradients
  14369. */
  14370. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14371. /**
  14372. * Adds a new life time gradient
  14373. * @param gradient defines the gradient to use (between 0 and 1)
  14374. * @param factor defines the life time factor to affect to the specified gradient
  14375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14376. * @returns the current particle system
  14377. */
  14378. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14379. /**
  14380. * Remove a specific life time gradient
  14381. * @param gradient defines the gradient to remove
  14382. * @returns the current particle system
  14383. */
  14384. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14385. /**
  14386. * Gets the current list of life time gradients.
  14387. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14388. * @returns the list of life time gradients
  14389. */
  14390. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14391. /**
  14392. * Gets the current list of color gradients.
  14393. * You must use addColorGradient and removeColorGradient to udpate this list
  14394. * @returns the list of color gradients
  14395. */
  14396. getColorGradients(): Nullable<Array<ColorGradient>>;
  14397. /**
  14398. * Adds a new ramp gradient used to remap particle colors
  14399. * @param gradient defines the gradient to use (between 0 and 1)
  14400. * @param color defines the color to affect to the specified gradient
  14401. * @returns the current particle system
  14402. */
  14403. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14404. /**
  14405. * Gets the current list of ramp gradients.
  14406. * You must use addRampGradient and removeRampGradient to udpate this list
  14407. * @returns the list of ramp gradients
  14408. */
  14409. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14410. /** Gets or sets a boolean indicating that ramp gradients must be used
  14411. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14412. */
  14413. useRampGradients: boolean;
  14414. /**
  14415. * Adds a new color remap gradient
  14416. * @param gradient defines the gradient to use (between 0 and 1)
  14417. * @param min defines the color remap minimal range
  14418. * @param max defines the color remap maximal range
  14419. * @returns the current particle system
  14420. */
  14421. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14422. /**
  14423. * Gets the current list of color remap gradients.
  14424. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14425. * @returns the list of color remap gradients
  14426. */
  14427. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14428. /**
  14429. * Adds a new alpha remap gradient
  14430. * @param gradient defines the gradient to use (between 0 and 1)
  14431. * @param min defines the alpha remap minimal range
  14432. * @param max defines the alpha remap maximal range
  14433. * @returns the current particle system
  14434. */
  14435. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14436. /**
  14437. * Gets the current list of alpha remap gradients.
  14438. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14439. * @returns the list of alpha remap gradients
  14440. */
  14441. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14442. /**
  14443. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14444. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14445. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14446. * @returns the emitter
  14447. */
  14448. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14449. /**
  14450. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14451. * @param radius The radius of the hemisphere to emit from
  14452. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14453. * @returns the emitter
  14454. */
  14455. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14456. /**
  14457. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14458. * @param radius The radius of the sphere to emit from
  14459. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14460. * @returns the emitter
  14461. */
  14462. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14463. /**
  14464. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14465. * @param radius The radius of the sphere to emit from
  14466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14468. * @returns the emitter
  14469. */
  14470. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14471. /**
  14472. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14473. * @param radius The radius of the emission cylinder
  14474. * @param height The height of the emission cylinder
  14475. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14476. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14477. * @returns the emitter
  14478. */
  14479. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14480. /**
  14481. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14482. * @param radius The radius of the cylinder to emit from
  14483. * @param height The height of the emission cylinder
  14484. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14487. * @returns the emitter
  14488. */
  14489. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14490. /**
  14491. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14492. * @param radius The radius of the cone to emit from
  14493. * @param angle The base angle of the cone
  14494. * @returns the emitter
  14495. */
  14496. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14497. /**
  14498. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14499. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14500. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14501. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14502. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14503. * @returns the emitter
  14504. */
  14505. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14506. /**
  14507. * Get hosting scene
  14508. * @returns the scene
  14509. */
  14510. getScene(): Scene;
  14511. }
  14512. }
  14513. declare module BABYLON {
  14514. /**
  14515. * 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.
  14516. * @see https://doc.babylonjs.com/how_to/transformnode
  14517. */
  14518. export class TransformNode extends Node {
  14519. /**
  14520. * Object will not rotate to face the camera
  14521. */
  14522. static BILLBOARDMODE_NONE: number;
  14523. /**
  14524. * Object will rotate to face the camera but only on the x axis
  14525. */
  14526. static BILLBOARDMODE_X: number;
  14527. /**
  14528. * Object will rotate to face the camera but only on the y axis
  14529. */
  14530. static BILLBOARDMODE_Y: number;
  14531. /**
  14532. * Object will rotate to face the camera but only on the z axis
  14533. */
  14534. static BILLBOARDMODE_Z: number;
  14535. /**
  14536. * Object will rotate to face the camera
  14537. */
  14538. static BILLBOARDMODE_ALL: number;
  14539. /**
  14540. * Object will rotate to face the camera's position instead of orientation
  14541. */
  14542. static BILLBOARDMODE_USE_POSITION: number;
  14543. private _forward;
  14544. private _forwardInverted;
  14545. private _up;
  14546. private _right;
  14547. private _rightInverted;
  14548. private _position;
  14549. private _rotation;
  14550. private _rotationQuaternion;
  14551. protected _scaling: Vector3;
  14552. protected _isDirty: boolean;
  14553. private _transformToBoneReferal;
  14554. private _isAbsoluteSynced;
  14555. private _billboardMode;
  14556. /**
  14557. * Gets or sets the billboard mode. Default is 0.
  14558. *
  14559. * | Value | Type | Description |
  14560. * | --- | --- | --- |
  14561. * | 0 | BILLBOARDMODE_NONE | |
  14562. * | 1 | BILLBOARDMODE_X | |
  14563. * | 2 | BILLBOARDMODE_Y | |
  14564. * | 4 | BILLBOARDMODE_Z | |
  14565. * | 7 | BILLBOARDMODE_ALL | |
  14566. *
  14567. */
  14568. get billboardMode(): number;
  14569. set billboardMode(value: number);
  14570. private _preserveParentRotationForBillboard;
  14571. /**
  14572. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14573. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14574. */
  14575. get preserveParentRotationForBillboard(): boolean;
  14576. set preserveParentRotationForBillboard(value: boolean);
  14577. /**
  14578. * 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
  14579. */
  14580. scalingDeterminant: number;
  14581. private _infiniteDistance;
  14582. /**
  14583. * Gets or sets the distance of the object to max, often used by skybox
  14584. */
  14585. get infiniteDistance(): boolean;
  14586. set infiniteDistance(value: boolean);
  14587. /**
  14588. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14589. * By default the system will update normals to compensate
  14590. */
  14591. ignoreNonUniformScaling: boolean;
  14592. /**
  14593. * 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
  14594. */
  14595. reIntegrateRotationIntoRotationQuaternion: boolean;
  14596. /** @hidden */
  14597. _poseMatrix: Nullable<Matrix>;
  14598. /** @hidden */
  14599. _localMatrix: Matrix;
  14600. private _usePivotMatrix;
  14601. private _absolutePosition;
  14602. private _absoluteScaling;
  14603. private _absoluteRotationQuaternion;
  14604. private _pivotMatrix;
  14605. private _pivotMatrixInverse;
  14606. protected _postMultiplyPivotMatrix: boolean;
  14607. protected _isWorldMatrixFrozen: boolean;
  14608. /** @hidden */
  14609. _indexInSceneTransformNodesArray: number;
  14610. /**
  14611. * An event triggered after the world matrix is updated
  14612. */
  14613. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14614. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14615. /**
  14616. * Gets a string identifying the name of the class
  14617. * @returns "TransformNode" string
  14618. */
  14619. getClassName(): string;
  14620. /**
  14621. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14622. */
  14623. get position(): Vector3;
  14624. set position(newPosition: Vector3);
  14625. /**
  14626. * 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)).
  14627. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14628. */
  14629. get rotation(): Vector3;
  14630. set rotation(newRotation: Vector3);
  14631. /**
  14632. * 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)).
  14633. */
  14634. get scaling(): Vector3;
  14635. set scaling(newScaling: Vector3);
  14636. /**
  14637. * 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).
  14638. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14639. */
  14640. get rotationQuaternion(): Nullable<Quaternion>;
  14641. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14642. /**
  14643. * The forward direction of that transform in world space.
  14644. */
  14645. get forward(): Vector3;
  14646. /**
  14647. * The up direction of that transform in world space.
  14648. */
  14649. get up(): Vector3;
  14650. /**
  14651. * The right direction of that transform in world space.
  14652. */
  14653. get right(): Vector3;
  14654. /**
  14655. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14656. * @param matrix the matrix to copy the pose from
  14657. * @returns this TransformNode.
  14658. */
  14659. updatePoseMatrix(matrix: Matrix): TransformNode;
  14660. /**
  14661. * Returns the mesh Pose matrix.
  14662. * @returns the pose matrix
  14663. */
  14664. getPoseMatrix(): Matrix;
  14665. /** @hidden */
  14666. _isSynchronized(): boolean;
  14667. /** @hidden */
  14668. _initCache(): void;
  14669. /**
  14670. * Flag the transform node as dirty (Forcing it to update everything)
  14671. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14672. * @returns this transform node
  14673. */
  14674. markAsDirty(property: string): TransformNode;
  14675. /**
  14676. * Returns the current mesh absolute position.
  14677. * Returns a Vector3.
  14678. */
  14679. get absolutePosition(): Vector3;
  14680. /**
  14681. * Returns the current mesh absolute scaling.
  14682. * Returns a Vector3.
  14683. */
  14684. get absoluteScaling(): Vector3;
  14685. /**
  14686. * Returns the current mesh absolute rotation.
  14687. * Returns a Quaternion.
  14688. */
  14689. get absoluteRotationQuaternion(): Quaternion;
  14690. /**
  14691. * Sets a new matrix to apply before all other transformation
  14692. * @param matrix defines the transform matrix
  14693. * @returns the current TransformNode
  14694. */
  14695. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14696. /**
  14697. * Sets a new pivot matrix to the current node
  14698. * @param matrix defines the new pivot matrix to use
  14699. * @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
  14700. * @returns the current TransformNode
  14701. */
  14702. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14703. /**
  14704. * Returns the mesh pivot matrix.
  14705. * Default : Identity.
  14706. * @returns the matrix
  14707. */
  14708. getPivotMatrix(): Matrix;
  14709. /**
  14710. * Instantiate (when possible) or clone that node with its hierarchy
  14711. * @param newParent defines the new parent to use for the instance (or clone)
  14712. * @param options defines options to configure how copy is done
  14713. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14714. * @returns an instance (or a clone) of the current node with its hiearchy
  14715. */
  14716. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14717. doNotInstantiate: boolean;
  14718. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14719. /**
  14720. * Prevents the World matrix to be computed any longer
  14721. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14722. * @returns the TransformNode.
  14723. */
  14724. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14725. /**
  14726. * Allows back the World matrix computation.
  14727. * @returns the TransformNode.
  14728. */
  14729. unfreezeWorldMatrix(): this;
  14730. /**
  14731. * True if the World matrix has been frozen.
  14732. */
  14733. get isWorldMatrixFrozen(): boolean;
  14734. /**
  14735. * Retuns the mesh absolute position in the World.
  14736. * @returns a Vector3.
  14737. */
  14738. getAbsolutePosition(): Vector3;
  14739. /**
  14740. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14741. * @param absolutePosition the absolute position to set
  14742. * @returns the TransformNode.
  14743. */
  14744. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14745. /**
  14746. * Sets the mesh position in its local space.
  14747. * @param vector3 the position to set in localspace
  14748. * @returns the TransformNode.
  14749. */
  14750. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14751. /**
  14752. * Returns the mesh position in the local space from the current World matrix values.
  14753. * @returns a new Vector3.
  14754. */
  14755. getPositionExpressedInLocalSpace(): Vector3;
  14756. /**
  14757. * Translates the mesh along the passed Vector3 in its local space.
  14758. * @param vector3 the distance to translate in localspace
  14759. * @returns the TransformNode.
  14760. */
  14761. locallyTranslate(vector3: Vector3): TransformNode;
  14762. private static _lookAtVectorCache;
  14763. /**
  14764. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14765. * @param targetPoint the position (must be in same space as current mesh) to look at
  14766. * @param yawCor optional yaw (y-axis) correction in radians
  14767. * @param pitchCor optional pitch (x-axis) correction in radians
  14768. * @param rollCor optional roll (z-axis) correction in radians
  14769. * @param space the choosen space of the target
  14770. * @returns the TransformNode.
  14771. */
  14772. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14773. /**
  14774. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14775. * This Vector3 is expressed in the World space.
  14776. * @param localAxis axis to rotate
  14777. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14778. */
  14779. getDirection(localAxis: Vector3): Vector3;
  14780. /**
  14781. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14782. * localAxis is expressed in the mesh local space.
  14783. * result is computed in the Wordl space from the mesh World matrix.
  14784. * @param localAxis axis to rotate
  14785. * @param result the resulting transformnode
  14786. * @returns this TransformNode.
  14787. */
  14788. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14789. /**
  14790. * Sets this transform node rotation to the given local axis.
  14791. * @param localAxis the axis in local space
  14792. * @param yawCor optional yaw (y-axis) correction in radians
  14793. * @param pitchCor optional pitch (x-axis) correction in radians
  14794. * @param rollCor optional roll (z-axis) correction in radians
  14795. * @returns this TransformNode
  14796. */
  14797. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14798. /**
  14799. * Sets a new pivot point to the current node
  14800. * @param point defines the new pivot point to use
  14801. * @param space defines if the point is in world or local space (local by default)
  14802. * @returns the current TransformNode
  14803. */
  14804. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14805. /**
  14806. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14807. * @returns the pivot point
  14808. */
  14809. getPivotPoint(): Vector3;
  14810. /**
  14811. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14812. * @param result the vector3 to store the result
  14813. * @returns this TransformNode.
  14814. */
  14815. getPivotPointToRef(result: Vector3): TransformNode;
  14816. /**
  14817. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14818. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14819. */
  14820. getAbsolutePivotPoint(): Vector3;
  14821. /**
  14822. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14823. * @param result vector3 to store the result
  14824. * @returns this TransformNode.
  14825. */
  14826. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14827. /**
  14828. * Defines the passed node as the parent of the current node.
  14829. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14830. * @see https://doc.babylonjs.com/how_to/parenting
  14831. * @param node the node ot set as the parent
  14832. * @returns this TransformNode.
  14833. */
  14834. setParent(node: Nullable<Node>): TransformNode;
  14835. private _nonUniformScaling;
  14836. /**
  14837. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14838. */
  14839. get nonUniformScaling(): boolean;
  14840. /** @hidden */
  14841. _updateNonUniformScalingState(value: boolean): boolean;
  14842. /**
  14843. * Attach the current TransformNode to another TransformNode associated with a bone
  14844. * @param bone Bone affecting the TransformNode
  14845. * @param affectedTransformNode TransformNode associated with the bone
  14846. * @returns this object
  14847. */
  14848. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14849. /**
  14850. * Detach the transform node if its associated with a bone
  14851. * @returns this object
  14852. */
  14853. detachFromBone(): TransformNode;
  14854. private static _rotationAxisCache;
  14855. /**
  14856. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14857. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14858. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14859. * The passed axis is also normalized.
  14860. * @param axis the axis to rotate around
  14861. * @param amount the amount to rotate in radians
  14862. * @param space Space to rotate in (Default: local)
  14863. * @returns the TransformNode.
  14864. */
  14865. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14866. /**
  14867. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14868. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14869. * The passed axis is also normalized. .
  14870. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14871. * @param point the point to rotate around
  14872. * @param axis the axis to rotate around
  14873. * @param amount the amount to rotate in radians
  14874. * @returns the TransformNode
  14875. */
  14876. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14877. /**
  14878. * Translates the mesh along the axis vector for the passed distance in the given space.
  14879. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14880. * @param axis the axis to translate in
  14881. * @param distance the distance to translate
  14882. * @param space Space to rotate in (Default: local)
  14883. * @returns the TransformNode.
  14884. */
  14885. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14886. /**
  14887. * Adds a rotation step to the mesh current rotation.
  14888. * x, y, z are Euler angles expressed in radians.
  14889. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14890. * This means this rotation is made in the mesh local space only.
  14891. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14892. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14893. * ```javascript
  14894. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14895. * ```
  14896. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14897. * 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.
  14898. * @param x Rotation to add
  14899. * @param y Rotation to add
  14900. * @param z Rotation to add
  14901. * @returns the TransformNode.
  14902. */
  14903. addRotation(x: number, y: number, z: number): TransformNode;
  14904. /**
  14905. * @hidden
  14906. */
  14907. protected _getEffectiveParent(): Nullable<Node>;
  14908. /**
  14909. * Computes the world matrix of the node
  14910. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14911. * @returns the world matrix
  14912. */
  14913. computeWorldMatrix(force?: boolean): Matrix;
  14914. /**
  14915. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14916. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14917. */
  14918. resetLocalMatrix(independentOfChildren?: boolean): void;
  14919. protected _afterComputeWorldMatrix(): void;
  14920. /**
  14921. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14922. * @param func callback function to add
  14923. *
  14924. * @returns the TransformNode.
  14925. */
  14926. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14927. /**
  14928. * Removes a registered callback function.
  14929. * @param func callback function to remove
  14930. * @returns the TransformNode.
  14931. */
  14932. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14933. /**
  14934. * Gets the position of the current mesh in camera space
  14935. * @param camera defines the camera to use
  14936. * @returns a position
  14937. */
  14938. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14939. /**
  14940. * Returns the distance from the mesh to the active camera
  14941. * @param camera defines the camera to use
  14942. * @returns the distance
  14943. */
  14944. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14945. /**
  14946. * Clone the current transform node
  14947. * @param name Name of the new clone
  14948. * @param newParent New parent for the clone
  14949. * @param doNotCloneChildren Do not clone children hierarchy
  14950. * @returns the new transform node
  14951. */
  14952. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14953. /**
  14954. * Serializes the objects information.
  14955. * @param currentSerializationObject defines the object to serialize in
  14956. * @returns the serialized object
  14957. */
  14958. serialize(currentSerializationObject?: any): any;
  14959. /**
  14960. * Returns a new TransformNode object parsed from the source provided.
  14961. * @param parsedTransformNode is the source.
  14962. * @param scene the scne the object belongs to
  14963. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14964. * @returns a new TransformNode object parsed from the source provided.
  14965. */
  14966. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14967. /**
  14968. * Get all child-transformNodes of this node
  14969. * @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
  14970. * @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
  14971. * @returns an array of TransformNode
  14972. */
  14973. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14974. /**
  14975. * Releases resources associated with this transform node.
  14976. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14977. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14978. */
  14979. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14980. /**
  14981. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14982. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14983. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14984. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14985. * @returns the current mesh
  14986. */
  14987. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14988. private _syncAbsoluteScalingAndRotation;
  14989. }
  14990. }
  14991. declare module BABYLON {
  14992. /**
  14993. * Class used to override all child animations of a given target
  14994. */
  14995. export class AnimationPropertiesOverride {
  14996. /**
  14997. * Gets or sets a value indicating if animation blending must be used
  14998. */
  14999. enableBlending: boolean;
  15000. /**
  15001. * Gets or sets the blending speed to use when enableBlending is true
  15002. */
  15003. blendingSpeed: number;
  15004. /**
  15005. * Gets or sets the default loop mode to use
  15006. */
  15007. loopMode: number;
  15008. }
  15009. }
  15010. declare module BABYLON {
  15011. /**
  15012. * Class used to store bone information
  15013. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15014. */
  15015. export class Bone extends Node {
  15016. /**
  15017. * defines the bone name
  15018. */
  15019. name: string;
  15020. private static _tmpVecs;
  15021. private static _tmpQuat;
  15022. private static _tmpMats;
  15023. /**
  15024. * Gets the list of child bones
  15025. */
  15026. children: Bone[];
  15027. /** Gets the animations associated with this bone */
  15028. animations: Animation[];
  15029. /**
  15030. * Gets or sets bone length
  15031. */
  15032. length: number;
  15033. /**
  15034. * @hidden Internal only
  15035. * Set this value to map this bone to a different index in the transform matrices
  15036. * Set this value to -1 to exclude the bone from the transform matrices
  15037. */
  15038. _index: Nullable<number>;
  15039. private _skeleton;
  15040. private _localMatrix;
  15041. private _restPose;
  15042. private _baseMatrix;
  15043. private _absoluteTransform;
  15044. private _invertedAbsoluteTransform;
  15045. private _parent;
  15046. private _scalingDeterminant;
  15047. private _worldTransform;
  15048. private _localScaling;
  15049. private _localRotation;
  15050. private _localPosition;
  15051. private _needToDecompose;
  15052. private _needToCompose;
  15053. /** @hidden */
  15054. _linkedTransformNode: Nullable<TransformNode>;
  15055. /** @hidden */
  15056. _waitingTransformNodeId: Nullable<string>;
  15057. /** @hidden */
  15058. get _matrix(): Matrix;
  15059. /** @hidden */
  15060. set _matrix(value: Matrix);
  15061. /**
  15062. * Create a new bone
  15063. * @param name defines the bone name
  15064. * @param skeleton defines the parent skeleton
  15065. * @param parentBone defines the parent (can be null if the bone is the root)
  15066. * @param localMatrix defines the local matrix
  15067. * @param restPose defines the rest pose matrix
  15068. * @param baseMatrix defines the base matrix
  15069. * @param index defines index of the bone in the hiearchy
  15070. */
  15071. constructor(
  15072. /**
  15073. * defines the bone name
  15074. */
  15075. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15076. /**
  15077. * Gets the current object class name.
  15078. * @return the class name
  15079. */
  15080. getClassName(): string;
  15081. /**
  15082. * Gets the parent skeleton
  15083. * @returns a skeleton
  15084. */
  15085. getSkeleton(): Skeleton;
  15086. /**
  15087. * Gets parent bone
  15088. * @returns a bone or null if the bone is the root of the bone hierarchy
  15089. */
  15090. getParent(): Nullable<Bone>;
  15091. /**
  15092. * Returns an array containing the root bones
  15093. * @returns an array containing the root bones
  15094. */
  15095. getChildren(): Array<Bone>;
  15096. /**
  15097. * Gets the node index in matrix array generated for rendering
  15098. * @returns the node index
  15099. */
  15100. getIndex(): number;
  15101. /**
  15102. * Sets the parent bone
  15103. * @param parent defines the parent (can be null if the bone is the root)
  15104. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15105. */
  15106. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15107. /**
  15108. * Gets the local matrix
  15109. * @returns a matrix
  15110. */
  15111. getLocalMatrix(): Matrix;
  15112. /**
  15113. * Gets the base matrix (initial matrix which remains unchanged)
  15114. * @returns a matrix
  15115. */
  15116. getBaseMatrix(): Matrix;
  15117. /**
  15118. * Gets the rest pose matrix
  15119. * @returns a matrix
  15120. */
  15121. getRestPose(): Matrix;
  15122. /**
  15123. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15124. */
  15125. getWorldMatrix(): Matrix;
  15126. /**
  15127. * Sets the local matrix to rest pose matrix
  15128. */
  15129. returnToRest(): void;
  15130. /**
  15131. * Gets the inverse of the absolute transform matrix.
  15132. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15133. * @returns a matrix
  15134. */
  15135. getInvertedAbsoluteTransform(): Matrix;
  15136. /**
  15137. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15138. * @returns a matrix
  15139. */
  15140. getAbsoluteTransform(): Matrix;
  15141. /**
  15142. * Links with the given transform node.
  15143. * The local matrix of this bone is copied from the transform node every frame.
  15144. * @param transformNode defines the transform node to link to
  15145. */
  15146. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15147. /**
  15148. * Gets the node used to drive the bone's transformation
  15149. * @returns a transform node or null
  15150. */
  15151. getTransformNode(): Nullable<TransformNode>;
  15152. /** Gets or sets current position (in local space) */
  15153. get position(): Vector3;
  15154. set position(newPosition: Vector3);
  15155. /** Gets or sets current rotation (in local space) */
  15156. get rotation(): Vector3;
  15157. set rotation(newRotation: Vector3);
  15158. /** Gets or sets current rotation quaternion (in local space) */
  15159. get rotationQuaternion(): Quaternion;
  15160. set rotationQuaternion(newRotation: Quaternion);
  15161. /** Gets or sets current scaling (in local space) */
  15162. get scaling(): Vector3;
  15163. set scaling(newScaling: Vector3);
  15164. /**
  15165. * Gets the animation properties override
  15166. */
  15167. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15168. private _decompose;
  15169. private _compose;
  15170. /**
  15171. * Update the base and local matrices
  15172. * @param matrix defines the new base or local matrix
  15173. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15174. * @param updateLocalMatrix defines if the local matrix should be updated
  15175. */
  15176. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15177. /** @hidden */
  15178. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15179. /**
  15180. * Flag the bone as dirty (Forcing it to update everything)
  15181. */
  15182. markAsDirty(): void;
  15183. /** @hidden */
  15184. _markAsDirtyAndCompose(): void;
  15185. private _markAsDirtyAndDecompose;
  15186. /**
  15187. * Translate the bone in local or world space
  15188. * @param vec The amount to translate the bone
  15189. * @param space The space that the translation is in
  15190. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15191. */
  15192. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15193. /**
  15194. * Set the postion of the bone in local or world space
  15195. * @param position The position to set the bone
  15196. * @param space The space that the position is in
  15197. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15198. */
  15199. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15200. /**
  15201. * Set the absolute position of the bone (world space)
  15202. * @param position The position to set the bone
  15203. * @param mesh The mesh that this bone is attached to
  15204. */
  15205. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15206. /**
  15207. * Scale the bone on the x, y and z axes (in local space)
  15208. * @param x The amount to scale the bone on the x axis
  15209. * @param y The amount to scale the bone on the y axis
  15210. * @param z The amount to scale the bone on the z axis
  15211. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15212. */
  15213. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15214. /**
  15215. * Set the bone scaling in local space
  15216. * @param scale defines the scaling vector
  15217. */
  15218. setScale(scale: Vector3): void;
  15219. /**
  15220. * Gets the current scaling in local space
  15221. * @returns the current scaling vector
  15222. */
  15223. getScale(): Vector3;
  15224. /**
  15225. * Gets the current scaling in local space and stores it in a target vector
  15226. * @param result defines the target vector
  15227. */
  15228. getScaleToRef(result: Vector3): void;
  15229. /**
  15230. * Set the yaw, pitch, and roll of the bone in local or world space
  15231. * @param yaw The rotation of the bone on the y axis
  15232. * @param pitch The rotation of the bone on the x axis
  15233. * @param roll The rotation of the bone on the z axis
  15234. * @param space The space that the axes of rotation are in
  15235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15236. */
  15237. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15238. /**
  15239. * Add a rotation to the bone on an axis in local or world space
  15240. * @param axis The axis to rotate the bone on
  15241. * @param amount The amount to rotate the bone
  15242. * @param space The space that the axis is in
  15243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15244. */
  15245. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15246. /**
  15247. * Set the rotation of the bone to a particular axis angle in local or world space
  15248. * @param axis The axis to rotate the bone on
  15249. * @param angle The angle that the bone should be rotated to
  15250. * @param space The space that the axis is in
  15251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15252. */
  15253. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15254. /**
  15255. * Set the euler rotation of the bone in local of world space
  15256. * @param rotation The euler rotation that the bone should be set to
  15257. * @param space The space that the rotation is in
  15258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15259. */
  15260. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15261. /**
  15262. * Set the quaternion rotation of the bone in local of world space
  15263. * @param quat The quaternion rotation that the bone should be set to
  15264. * @param space The space that the rotation is in
  15265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15266. */
  15267. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15268. /**
  15269. * Set the rotation matrix of the bone in local of world space
  15270. * @param rotMat The rotation matrix that the bone should be set to
  15271. * @param space The space that the rotation is in
  15272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15273. */
  15274. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15275. private _rotateWithMatrix;
  15276. private _getNegativeRotationToRef;
  15277. /**
  15278. * Get the position of the bone in local or world space
  15279. * @param space The space that the returned position is in
  15280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15281. * @returns The position of the bone
  15282. */
  15283. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15284. /**
  15285. * Copy the position of the bone to a vector3 in local or world space
  15286. * @param space The space that the returned position is in
  15287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15288. * @param result The vector3 to copy the position to
  15289. */
  15290. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15291. /**
  15292. * Get the absolute position of the bone (world space)
  15293. * @param mesh The mesh that this bone is attached to
  15294. * @returns The absolute position of the bone
  15295. */
  15296. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15297. /**
  15298. * Copy the absolute position of the bone (world space) to the result param
  15299. * @param mesh The mesh that this bone is attached to
  15300. * @param result The vector3 to copy the absolute position to
  15301. */
  15302. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15303. /**
  15304. * Compute the absolute transforms of this bone and its children
  15305. */
  15306. computeAbsoluteTransforms(): void;
  15307. /**
  15308. * Get the world direction from an axis that is in the local space of the bone
  15309. * @param localAxis The local direction that is used to compute the world direction
  15310. * @param mesh The mesh that this bone is attached to
  15311. * @returns The world direction
  15312. */
  15313. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15314. /**
  15315. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15316. * @param localAxis The local direction that is used to compute the world direction
  15317. * @param mesh The mesh that this bone is attached to
  15318. * @param result The vector3 that the world direction will be copied to
  15319. */
  15320. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15321. /**
  15322. * Get the euler rotation of the bone in local or world space
  15323. * @param space The space that the rotation should be in
  15324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15325. * @returns The euler rotation
  15326. */
  15327. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15328. /**
  15329. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15330. * @param space The space that the rotation should be in
  15331. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15332. * @param result The vector3 that the rotation should be copied to
  15333. */
  15334. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15335. /**
  15336. * Get the quaternion rotation of the bone in either local or world space
  15337. * @param space The space that the rotation should be in
  15338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15339. * @returns The quaternion rotation
  15340. */
  15341. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15342. /**
  15343. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15344. * @param space The space that the rotation should be in
  15345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15346. * @param result The quaternion that the rotation should be copied to
  15347. */
  15348. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15349. /**
  15350. * Get the rotation matrix of the bone in local or world space
  15351. * @param space The space that the rotation should be in
  15352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15353. * @returns The rotation matrix
  15354. */
  15355. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15356. /**
  15357. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15358. * @param space The space that the rotation should be in
  15359. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15360. * @param result The quaternion that the rotation should be copied to
  15361. */
  15362. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15363. /**
  15364. * Get the world position of a point that is in the local space of the bone
  15365. * @param position The local position
  15366. * @param mesh The mesh that this bone is attached to
  15367. * @returns The world position
  15368. */
  15369. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15370. /**
  15371. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15372. * @param position The local position
  15373. * @param mesh The mesh that this bone is attached to
  15374. * @param result The vector3 that the world position should be copied to
  15375. */
  15376. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15377. /**
  15378. * Get the local position of a point that is in world space
  15379. * @param position The world position
  15380. * @param mesh The mesh that this bone is attached to
  15381. * @returns The local position
  15382. */
  15383. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15384. /**
  15385. * Get the local position of a point that is in world space and copy it to the result param
  15386. * @param position The world position
  15387. * @param mesh The mesh that this bone is attached to
  15388. * @param result The vector3 that the local position should be copied to
  15389. */
  15390. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15391. }
  15392. }
  15393. declare module BABYLON {
  15394. /**
  15395. * Defines a runtime animation
  15396. */
  15397. export class RuntimeAnimation {
  15398. private _events;
  15399. /**
  15400. * The current frame of the runtime animation
  15401. */
  15402. private _currentFrame;
  15403. /**
  15404. * The animation used by the runtime animation
  15405. */
  15406. private _animation;
  15407. /**
  15408. * The target of the runtime animation
  15409. */
  15410. private _target;
  15411. /**
  15412. * The initiating animatable
  15413. */
  15414. private _host;
  15415. /**
  15416. * The original value of the runtime animation
  15417. */
  15418. private _originalValue;
  15419. /**
  15420. * The original blend value of the runtime animation
  15421. */
  15422. private _originalBlendValue;
  15423. /**
  15424. * The offsets cache of the runtime animation
  15425. */
  15426. private _offsetsCache;
  15427. /**
  15428. * The high limits cache of the runtime animation
  15429. */
  15430. private _highLimitsCache;
  15431. /**
  15432. * Specifies if the runtime animation has been stopped
  15433. */
  15434. private _stopped;
  15435. /**
  15436. * The blending factor of the runtime animation
  15437. */
  15438. private _blendingFactor;
  15439. /**
  15440. * The BabylonJS scene
  15441. */
  15442. private _scene;
  15443. /**
  15444. * The current value of the runtime animation
  15445. */
  15446. private _currentValue;
  15447. /** @hidden */
  15448. _animationState: _IAnimationState;
  15449. /**
  15450. * The active target of the runtime animation
  15451. */
  15452. private _activeTargets;
  15453. private _currentActiveTarget;
  15454. private _directTarget;
  15455. /**
  15456. * The target path of the runtime animation
  15457. */
  15458. private _targetPath;
  15459. /**
  15460. * The weight of the runtime animation
  15461. */
  15462. private _weight;
  15463. /**
  15464. * The ratio offset of the runtime animation
  15465. */
  15466. private _ratioOffset;
  15467. /**
  15468. * The previous delay of the runtime animation
  15469. */
  15470. private _previousDelay;
  15471. /**
  15472. * The previous ratio of the runtime animation
  15473. */
  15474. private _previousRatio;
  15475. private _enableBlending;
  15476. private _keys;
  15477. private _minFrame;
  15478. private _maxFrame;
  15479. private _minValue;
  15480. private _maxValue;
  15481. private _targetIsArray;
  15482. /**
  15483. * Gets the current frame of the runtime animation
  15484. */
  15485. get currentFrame(): number;
  15486. /**
  15487. * Gets the weight of the runtime animation
  15488. */
  15489. get weight(): number;
  15490. /**
  15491. * Gets the current value of the runtime animation
  15492. */
  15493. get currentValue(): any;
  15494. /**
  15495. * Gets the target path of the runtime animation
  15496. */
  15497. get targetPath(): string;
  15498. /**
  15499. * Gets the actual target of the runtime animation
  15500. */
  15501. get target(): any;
  15502. /**
  15503. * Gets the additive state of the runtime animation
  15504. */
  15505. get isAdditive(): boolean;
  15506. /** @hidden */
  15507. _onLoop: () => void;
  15508. /**
  15509. * Create a new RuntimeAnimation object
  15510. * @param target defines the target of the animation
  15511. * @param animation defines the source animation object
  15512. * @param scene defines the hosting scene
  15513. * @param host defines the initiating Animatable
  15514. */
  15515. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15516. private _preparePath;
  15517. /**
  15518. * Gets the animation from the runtime animation
  15519. */
  15520. get animation(): Animation;
  15521. /**
  15522. * Resets the runtime animation to the beginning
  15523. * @param restoreOriginal defines whether to restore the target property to the original value
  15524. */
  15525. reset(restoreOriginal?: boolean): void;
  15526. /**
  15527. * Specifies if the runtime animation is stopped
  15528. * @returns Boolean specifying if the runtime animation is stopped
  15529. */
  15530. isStopped(): boolean;
  15531. /**
  15532. * Disposes of the runtime animation
  15533. */
  15534. dispose(): void;
  15535. /**
  15536. * Apply the interpolated value to the target
  15537. * @param currentValue defines the value computed by the animation
  15538. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15539. */
  15540. setValue(currentValue: any, weight: number): void;
  15541. private _getOriginalValues;
  15542. private _setValue;
  15543. /**
  15544. * Gets the loop pmode of the runtime animation
  15545. * @returns Loop Mode
  15546. */
  15547. private _getCorrectLoopMode;
  15548. /**
  15549. * Move the current animation to a given frame
  15550. * @param frame defines the frame to move to
  15551. */
  15552. goToFrame(frame: number): void;
  15553. /**
  15554. * @hidden Internal use only
  15555. */
  15556. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15557. /**
  15558. * Execute the current animation
  15559. * @param delay defines the delay to add to the current frame
  15560. * @param from defines the lower bound of the animation range
  15561. * @param to defines the upper bound of the animation range
  15562. * @param loop defines if the current animation must loop
  15563. * @param speedRatio defines the current speed ratio
  15564. * @param weight defines the weight of the animation (default is -1 so no weight)
  15565. * @param onLoop optional callback called when animation loops
  15566. * @returns a boolean indicating if the animation is running
  15567. */
  15568. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15569. }
  15570. }
  15571. declare module BABYLON {
  15572. /**
  15573. * Class used to store an actual running animation
  15574. */
  15575. export class Animatable {
  15576. /** defines the target object */
  15577. target: any;
  15578. /** defines the starting frame number (default is 0) */
  15579. fromFrame: number;
  15580. /** defines the ending frame number (default is 100) */
  15581. toFrame: number;
  15582. /** defines if the animation must loop (default is false) */
  15583. loopAnimation: boolean;
  15584. /** defines a callback to call when animation ends if it is not looping */
  15585. onAnimationEnd?: (() => void) | null | undefined;
  15586. /** defines a callback to call when animation loops */
  15587. onAnimationLoop?: (() => void) | null | undefined;
  15588. /** defines whether the animation should be evaluated additively */
  15589. isAdditive: boolean;
  15590. private _localDelayOffset;
  15591. private _pausedDelay;
  15592. private _runtimeAnimations;
  15593. private _paused;
  15594. private _scene;
  15595. private _speedRatio;
  15596. private _weight;
  15597. private _syncRoot;
  15598. /**
  15599. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15600. * This will only apply for non looping animation (default is true)
  15601. */
  15602. disposeOnEnd: boolean;
  15603. /**
  15604. * Gets a boolean indicating if the animation has started
  15605. */
  15606. animationStarted: boolean;
  15607. /**
  15608. * Observer raised when the animation ends
  15609. */
  15610. onAnimationEndObservable: Observable<Animatable>;
  15611. /**
  15612. * Observer raised when the animation loops
  15613. */
  15614. onAnimationLoopObservable: Observable<Animatable>;
  15615. /**
  15616. * Gets the root Animatable used to synchronize and normalize animations
  15617. */
  15618. get syncRoot(): Nullable<Animatable>;
  15619. /**
  15620. * Gets the current frame of the first RuntimeAnimation
  15621. * Used to synchronize Animatables
  15622. */
  15623. get masterFrame(): number;
  15624. /**
  15625. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15626. */
  15627. get weight(): number;
  15628. set weight(value: number);
  15629. /**
  15630. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15631. */
  15632. get speedRatio(): number;
  15633. set speedRatio(value: number);
  15634. /**
  15635. * Creates a new Animatable
  15636. * @param scene defines the hosting scene
  15637. * @param target defines the target object
  15638. * @param fromFrame defines the starting frame number (default is 0)
  15639. * @param toFrame defines the ending frame number (default is 100)
  15640. * @param loopAnimation defines if the animation must loop (default is false)
  15641. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15642. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15643. * @param animations defines a group of animation to add to the new Animatable
  15644. * @param onAnimationLoop defines a callback to call when animation loops
  15645. * @param isAdditive defines whether the animation should be evaluated additively
  15646. */
  15647. constructor(scene: Scene,
  15648. /** defines the target object */
  15649. target: any,
  15650. /** defines the starting frame number (default is 0) */
  15651. fromFrame?: number,
  15652. /** defines the ending frame number (default is 100) */
  15653. toFrame?: number,
  15654. /** defines if the animation must loop (default is false) */
  15655. loopAnimation?: boolean, speedRatio?: number,
  15656. /** defines a callback to call when animation ends if it is not looping */
  15657. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15658. /** defines a callback to call when animation loops */
  15659. onAnimationLoop?: (() => void) | null | undefined,
  15660. /** defines whether the animation should be evaluated additively */
  15661. isAdditive?: boolean);
  15662. /**
  15663. * Synchronize and normalize current Animatable with a source Animatable
  15664. * This is useful when using animation weights and when animations are not of the same length
  15665. * @param root defines the root Animatable to synchronize with
  15666. * @returns the current Animatable
  15667. */
  15668. syncWith(root: Animatable): Animatable;
  15669. /**
  15670. * Gets the list of runtime animations
  15671. * @returns an array of RuntimeAnimation
  15672. */
  15673. getAnimations(): RuntimeAnimation[];
  15674. /**
  15675. * Adds more animations to the current animatable
  15676. * @param target defines the target of the animations
  15677. * @param animations defines the new animations to add
  15678. */
  15679. appendAnimations(target: any, animations: Animation[]): void;
  15680. /**
  15681. * Gets the source animation for a specific property
  15682. * @param property defines the propertyu to look for
  15683. * @returns null or the source animation for the given property
  15684. */
  15685. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15686. /**
  15687. * Gets the runtime animation for a specific property
  15688. * @param property defines the propertyu to look for
  15689. * @returns null or the runtime animation for the given property
  15690. */
  15691. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15692. /**
  15693. * Resets the animatable to its original state
  15694. */
  15695. reset(): void;
  15696. /**
  15697. * Allows the animatable to blend with current running animations
  15698. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15699. * @param blendingSpeed defines the blending speed to use
  15700. */
  15701. enableBlending(blendingSpeed: number): void;
  15702. /**
  15703. * Disable animation blending
  15704. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15705. */
  15706. disableBlending(): void;
  15707. /**
  15708. * Jump directly to a given frame
  15709. * @param frame defines the frame to jump to
  15710. */
  15711. goToFrame(frame: number): void;
  15712. /**
  15713. * Pause the animation
  15714. */
  15715. pause(): void;
  15716. /**
  15717. * Restart the animation
  15718. */
  15719. restart(): void;
  15720. private _raiseOnAnimationEnd;
  15721. /**
  15722. * Stop and delete the current animation
  15723. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15724. * @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)
  15725. */
  15726. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15727. /**
  15728. * Wait asynchronously for the animation to end
  15729. * @returns a promise which will be fullfilled when the animation ends
  15730. */
  15731. waitAsync(): Promise<Animatable>;
  15732. /** @hidden */
  15733. _animate(delay: number): boolean;
  15734. }
  15735. interface Scene {
  15736. /** @hidden */
  15737. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15738. /** @hidden */
  15739. _processLateAnimationBindingsForMatrices(holder: {
  15740. totalWeight: number;
  15741. totalAdditiveWeight: number;
  15742. animations: RuntimeAnimation[];
  15743. additiveAnimations: RuntimeAnimation[];
  15744. originalValue: Matrix;
  15745. }): any;
  15746. /** @hidden */
  15747. _processLateAnimationBindingsForQuaternions(holder: {
  15748. totalWeight: number;
  15749. totalAdditiveWeight: number;
  15750. animations: RuntimeAnimation[];
  15751. additiveAnimations: RuntimeAnimation[];
  15752. originalValue: Quaternion;
  15753. }, refQuaternion: Quaternion): Quaternion;
  15754. /** @hidden */
  15755. _processLateAnimationBindings(): void;
  15756. /**
  15757. * Will start the animation sequence of a given target
  15758. * @param target defines the target
  15759. * @param from defines from which frame should animation start
  15760. * @param to defines until which frame should animation run.
  15761. * @param weight defines the weight to apply to the animation (1.0 by default)
  15762. * @param loop defines if the animation loops
  15763. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15764. * @param onAnimationEnd defines the function to be executed when the animation ends
  15765. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15766. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15767. * @param onAnimationLoop defines the callback to call when an animation loops
  15768. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15769. * @returns the animatable object created for this animation
  15770. */
  15771. 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;
  15772. /**
  15773. * Will start the animation sequence of a given target
  15774. * @param target defines the target
  15775. * @param from defines from which frame should animation start
  15776. * @param to defines until which frame should animation run.
  15777. * @param loop defines if the animation loops
  15778. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15779. * @param onAnimationEnd defines the function to be executed when the animation ends
  15780. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15781. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15782. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15783. * @param onAnimationLoop defines the callback to call when an animation loops
  15784. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15785. * @returns the animatable object created for this animation
  15786. */
  15787. 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;
  15788. /**
  15789. * Will start the animation sequence of a given target and its hierarchy
  15790. * @param target defines the target
  15791. * @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.
  15792. * @param from defines from which frame should animation start
  15793. * @param to defines until which frame should animation run.
  15794. * @param loop defines if the animation loops
  15795. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15796. * @param onAnimationEnd defines the function to be executed when the animation ends
  15797. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15798. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15799. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15800. * @param onAnimationLoop defines the callback to call when an animation loops
  15801. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15802. * @returns the list of created animatables
  15803. */
  15804. 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[];
  15805. /**
  15806. * Begin a new animation on a given node
  15807. * @param target defines the target where the animation will take place
  15808. * @param animations defines the list of animations to start
  15809. * @param from defines the initial value
  15810. * @param to defines the final value
  15811. * @param loop defines if you want animation to loop (off by default)
  15812. * @param speedRatio defines the speed ratio to apply to all animations
  15813. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15814. * @param onAnimationLoop defines the callback to call when an animation loops
  15815. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15816. * @returns the list of created animatables
  15817. */
  15818. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15819. /**
  15820. * Begin a new animation on a given node and its hierarchy
  15821. * @param target defines the root node where the animation will take place
  15822. * @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.
  15823. * @param animations defines the list of animations to start
  15824. * @param from defines the initial value
  15825. * @param to defines the final value
  15826. * @param loop defines if you want animation to loop (off by default)
  15827. * @param speedRatio defines the speed ratio to apply to all animations
  15828. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15829. * @param onAnimationLoop defines the callback to call when an animation loops
  15830. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15831. * @returns the list of animatables created for all nodes
  15832. */
  15833. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15834. /**
  15835. * Gets the animatable associated with a specific target
  15836. * @param target defines the target of the animatable
  15837. * @returns the required animatable if found
  15838. */
  15839. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15840. /**
  15841. * Gets all animatables associated with a given target
  15842. * @param target defines the target to look animatables for
  15843. * @returns an array of Animatables
  15844. */
  15845. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15846. /**
  15847. * Stops and removes all animations that have been applied to the scene
  15848. */
  15849. stopAllAnimations(): void;
  15850. /**
  15851. * Gets the current delta time used by animation engine
  15852. */
  15853. deltaTime: number;
  15854. }
  15855. interface Bone {
  15856. /**
  15857. * Copy an animation range from another bone
  15858. * @param source defines the source bone
  15859. * @param rangeName defines the range name to copy
  15860. * @param frameOffset defines the frame offset
  15861. * @param rescaleAsRequired defines if rescaling must be applied if required
  15862. * @param skelDimensionsRatio defines the scaling ratio
  15863. * @returns true if operation was successful
  15864. */
  15865. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15866. }
  15867. }
  15868. declare module BABYLON {
  15869. /**
  15870. * Class used to handle skinning animations
  15871. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15872. */
  15873. export class Skeleton implements IAnimatable {
  15874. /** defines the skeleton name */
  15875. name: string;
  15876. /** defines the skeleton Id */
  15877. id: string;
  15878. /**
  15879. * Defines the list of child bones
  15880. */
  15881. bones: Bone[];
  15882. /**
  15883. * Defines an estimate of the dimension of the skeleton at rest
  15884. */
  15885. dimensionsAtRest: Vector3;
  15886. /**
  15887. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15888. */
  15889. needInitialSkinMatrix: boolean;
  15890. /**
  15891. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15892. */
  15893. overrideMesh: Nullable<AbstractMesh>;
  15894. /**
  15895. * Gets the list of animations attached to this skeleton
  15896. */
  15897. animations: Array<Animation>;
  15898. private _scene;
  15899. private _isDirty;
  15900. private _transformMatrices;
  15901. private _transformMatrixTexture;
  15902. private _meshesWithPoseMatrix;
  15903. private _animatables;
  15904. private _identity;
  15905. private _synchronizedWithMesh;
  15906. private _ranges;
  15907. private _lastAbsoluteTransformsUpdateId;
  15908. private _canUseTextureForBones;
  15909. private _uniqueId;
  15910. /** @hidden */
  15911. _numBonesWithLinkedTransformNode: number;
  15912. /** @hidden */
  15913. _hasWaitingData: Nullable<boolean>;
  15914. /**
  15915. * Specifies if the skeleton should be serialized
  15916. */
  15917. doNotSerialize: boolean;
  15918. private _useTextureToStoreBoneMatrices;
  15919. /**
  15920. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15921. * Please note that this option is not available if the hardware does not support it
  15922. */
  15923. get useTextureToStoreBoneMatrices(): boolean;
  15924. set useTextureToStoreBoneMatrices(value: boolean);
  15925. private _animationPropertiesOverride;
  15926. /**
  15927. * Gets or sets the animation properties override
  15928. */
  15929. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15930. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15931. /**
  15932. * List of inspectable custom properties (used by the Inspector)
  15933. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15934. */
  15935. inspectableCustomProperties: IInspectable[];
  15936. /**
  15937. * An observable triggered before computing the skeleton's matrices
  15938. */
  15939. onBeforeComputeObservable: Observable<Skeleton>;
  15940. /**
  15941. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15942. */
  15943. get isUsingTextureForMatrices(): boolean;
  15944. /**
  15945. * Gets the unique ID of this skeleton
  15946. */
  15947. get uniqueId(): number;
  15948. /**
  15949. * Creates a new skeleton
  15950. * @param name defines the skeleton name
  15951. * @param id defines the skeleton Id
  15952. * @param scene defines the hosting scene
  15953. */
  15954. constructor(
  15955. /** defines the skeleton name */
  15956. name: string,
  15957. /** defines the skeleton Id */
  15958. id: string, scene: Scene);
  15959. /**
  15960. * Gets the current object class name.
  15961. * @return the class name
  15962. */
  15963. getClassName(): string;
  15964. /**
  15965. * Returns an array containing the root bones
  15966. * @returns an array containing the root bones
  15967. */
  15968. getChildren(): Array<Bone>;
  15969. /**
  15970. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15971. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15972. * @returns a Float32Array containing matrices data
  15973. */
  15974. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15975. /**
  15976. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15977. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15978. * @returns a raw texture containing the data
  15979. */
  15980. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15981. /**
  15982. * Gets the current hosting scene
  15983. * @returns a scene object
  15984. */
  15985. getScene(): Scene;
  15986. /**
  15987. * Gets a string representing the current skeleton data
  15988. * @param fullDetails defines a boolean indicating if we want a verbose version
  15989. * @returns a string representing the current skeleton data
  15990. */
  15991. toString(fullDetails?: boolean): string;
  15992. /**
  15993. * Get bone's index searching by name
  15994. * @param name defines bone's name to search for
  15995. * @return the indice of the bone. Returns -1 if not found
  15996. */
  15997. getBoneIndexByName(name: string): number;
  15998. /**
  15999. * Creater a new animation range
  16000. * @param name defines the name of the range
  16001. * @param from defines the start key
  16002. * @param to defines the end key
  16003. */
  16004. createAnimationRange(name: string, from: number, to: number): void;
  16005. /**
  16006. * Delete a specific animation range
  16007. * @param name defines the name of the range
  16008. * @param deleteFrames defines if frames must be removed as well
  16009. */
  16010. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16011. /**
  16012. * Gets a specific animation range
  16013. * @param name defines the name of the range to look for
  16014. * @returns the requested animation range or null if not found
  16015. */
  16016. getAnimationRange(name: string): Nullable<AnimationRange>;
  16017. /**
  16018. * Gets the list of all animation ranges defined on this skeleton
  16019. * @returns an array
  16020. */
  16021. getAnimationRanges(): Nullable<AnimationRange>[];
  16022. /**
  16023. * Copy animation range from a source skeleton.
  16024. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16025. * @param source defines the source skeleton
  16026. * @param name defines the name of the range to copy
  16027. * @param rescaleAsRequired defines if rescaling must be applied if required
  16028. * @returns true if operation was successful
  16029. */
  16030. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16031. /**
  16032. * Forces the skeleton to go to rest pose
  16033. */
  16034. returnToRest(): void;
  16035. private _getHighestAnimationFrame;
  16036. /**
  16037. * Begin a specific animation range
  16038. * @param name defines the name of the range to start
  16039. * @param loop defines if looping must be turned on (false by default)
  16040. * @param speedRatio defines the speed ratio to apply (1 by default)
  16041. * @param onAnimationEnd defines a callback which will be called when animation will end
  16042. * @returns a new animatable
  16043. */
  16044. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16045. /**
  16046. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16047. * @param skeleton defines the Skeleton containing the animation range to convert
  16048. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16049. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16050. * @returns the original skeleton
  16051. */
  16052. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16053. /** @hidden */
  16054. _markAsDirty(): void;
  16055. /** @hidden */
  16056. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16057. /** @hidden */
  16058. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16059. private _computeTransformMatrices;
  16060. /**
  16061. * Build all resources required to render a skeleton
  16062. */
  16063. prepare(): void;
  16064. /**
  16065. * Gets the list of animatables currently running for this skeleton
  16066. * @returns an array of animatables
  16067. */
  16068. getAnimatables(): IAnimatable[];
  16069. /**
  16070. * Clone the current skeleton
  16071. * @param name defines the name of the new skeleton
  16072. * @param id defines the id of the new skeleton
  16073. * @returns the new skeleton
  16074. */
  16075. clone(name: string, id?: string): Skeleton;
  16076. /**
  16077. * Enable animation blending for this skeleton
  16078. * @param blendingSpeed defines the blending speed to apply
  16079. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16080. */
  16081. enableBlending(blendingSpeed?: number): void;
  16082. /**
  16083. * Releases all resources associated with the current skeleton
  16084. */
  16085. dispose(): void;
  16086. /**
  16087. * Serialize the skeleton in a JSON object
  16088. * @returns a JSON object
  16089. */
  16090. serialize(): any;
  16091. /**
  16092. * Creates a new skeleton from serialized data
  16093. * @param parsedSkeleton defines the serialized data
  16094. * @param scene defines the hosting scene
  16095. * @returns a new skeleton
  16096. */
  16097. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16098. /**
  16099. * Compute all node absolute transforms
  16100. * @param forceUpdate defines if computation must be done even if cache is up to date
  16101. */
  16102. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16103. /**
  16104. * Gets the root pose matrix
  16105. * @returns a matrix
  16106. */
  16107. getPoseMatrix(): Nullable<Matrix>;
  16108. /**
  16109. * Sorts bones per internal index
  16110. */
  16111. sortBones(): void;
  16112. private _sortBones;
  16113. }
  16114. }
  16115. declare module BABYLON {
  16116. /**
  16117. * Creates an instance based on a source mesh.
  16118. */
  16119. export class InstancedMesh extends AbstractMesh {
  16120. private _sourceMesh;
  16121. private _currentLOD;
  16122. /** @hidden */
  16123. _indexInSourceMeshInstanceArray: number;
  16124. constructor(name: string, source: Mesh);
  16125. /**
  16126. * Returns the string "InstancedMesh".
  16127. */
  16128. getClassName(): string;
  16129. /** Gets the list of lights affecting that mesh */
  16130. get lightSources(): Light[];
  16131. _resyncLightSources(): void;
  16132. _resyncLightSource(light: Light): void;
  16133. _removeLightSource(light: Light, dispose: boolean): void;
  16134. /**
  16135. * If the source mesh receives shadows
  16136. */
  16137. get receiveShadows(): boolean;
  16138. /**
  16139. * The material of the source mesh
  16140. */
  16141. get material(): Nullable<Material>;
  16142. /**
  16143. * Visibility of the source mesh
  16144. */
  16145. get visibility(): number;
  16146. /**
  16147. * Skeleton of the source mesh
  16148. */
  16149. get skeleton(): Nullable<Skeleton>;
  16150. /**
  16151. * Rendering ground id of the source mesh
  16152. */
  16153. get renderingGroupId(): number;
  16154. set renderingGroupId(value: number);
  16155. /**
  16156. * Returns the total number of vertices (integer).
  16157. */
  16158. getTotalVertices(): number;
  16159. /**
  16160. * Returns a positive integer : the total number of indices in this mesh geometry.
  16161. * @returns the numner of indices or zero if the mesh has no geometry.
  16162. */
  16163. getTotalIndices(): number;
  16164. /**
  16165. * The source mesh of the instance
  16166. */
  16167. get sourceMesh(): Mesh;
  16168. /**
  16169. * Creates a new InstancedMesh object from the mesh model.
  16170. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16171. * @param name defines the name of the new instance
  16172. * @returns a new InstancedMesh
  16173. */
  16174. createInstance(name: string): InstancedMesh;
  16175. /**
  16176. * Is this node ready to be used/rendered
  16177. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16178. * @return {boolean} is it ready
  16179. */
  16180. isReady(completeCheck?: boolean): boolean;
  16181. /**
  16182. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16183. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16184. * @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.
  16185. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16186. */
  16187. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16188. /**
  16189. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16190. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16191. * The `data` are either a numeric array either a Float32Array.
  16192. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16193. * 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).
  16194. * Note that a new underlying VertexBuffer object is created each call.
  16195. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16196. *
  16197. * Possible `kind` values :
  16198. * - VertexBuffer.PositionKind
  16199. * - VertexBuffer.UVKind
  16200. * - VertexBuffer.UV2Kind
  16201. * - VertexBuffer.UV3Kind
  16202. * - VertexBuffer.UV4Kind
  16203. * - VertexBuffer.UV5Kind
  16204. * - VertexBuffer.UV6Kind
  16205. * - VertexBuffer.ColorKind
  16206. * - VertexBuffer.MatricesIndicesKind
  16207. * - VertexBuffer.MatricesIndicesExtraKind
  16208. * - VertexBuffer.MatricesWeightsKind
  16209. * - VertexBuffer.MatricesWeightsExtraKind
  16210. *
  16211. * Returns the Mesh.
  16212. */
  16213. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16214. /**
  16215. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16216. * If the mesh has no geometry, it is simply returned as it is.
  16217. * The `data` are either a numeric array either a Float32Array.
  16218. * No new underlying VertexBuffer object is created.
  16219. * 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.
  16220. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16221. *
  16222. * Possible `kind` values :
  16223. * - VertexBuffer.PositionKind
  16224. * - VertexBuffer.UVKind
  16225. * - VertexBuffer.UV2Kind
  16226. * - VertexBuffer.UV3Kind
  16227. * - VertexBuffer.UV4Kind
  16228. * - VertexBuffer.UV5Kind
  16229. * - VertexBuffer.UV6Kind
  16230. * - VertexBuffer.ColorKind
  16231. * - VertexBuffer.MatricesIndicesKind
  16232. * - VertexBuffer.MatricesIndicesExtraKind
  16233. * - VertexBuffer.MatricesWeightsKind
  16234. * - VertexBuffer.MatricesWeightsExtraKind
  16235. *
  16236. * Returns the Mesh.
  16237. */
  16238. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16239. /**
  16240. * Sets the mesh indices.
  16241. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16242. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16243. * This method creates a new index buffer each call.
  16244. * Returns the Mesh.
  16245. */
  16246. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16247. /**
  16248. * Boolean : True if the mesh owns the requested kind of data.
  16249. */
  16250. isVerticesDataPresent(kind: string): boolean;
  16251. /**
  16252. * Returns an array of indices (IndicesArray).
  16253. */
  16254. getIndices(): Nullable<IndicesArray>;
  16255. get _positions(): Nullable<Vector3[]>;
  16256. /**
  16257. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16258. * This means the mesh underlying bounding box and sphere are recomputed.
  16259. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16260. * @returns the current mesh
  16261. */
  16262. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16263. /** @hidden */
  16264. _preActivate(): InstancedMesh;
  16265. /** @hidden */
  16266. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16267. /** @hidden */
  16268. _postActivate(): void;
  16269. getWorldMatrix(): Matrix;
  16270. get isAnInstance(): boolean;
  16271. /**
  16272. * Returns the current associated LOD AbstractMesh.
  16273. */
  16274. getLOD(camera: Camera): AbstractMesh;
  16275. /** @hidden */
  16276. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16277. /** @hidden */
  16278. _syncSubMeshes(): InstancedMesh;
  16279. /** @hidden */
  16280. _generatePointsArray(): boolean;
  16281. /**
  16282. * Creates a new InstancedMesh from the current mesh.
  16283. * - name (string) : the cloned mesh name
  16284. * - newParent (optional Node) : the optional Node to parent the clone to.
  16285. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16286. *
  16287. * Returns the clone.
  16288. */
  16289. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16290. /**
  16291. * Disposes the InstancedMesh.
  16292. * Returns nothing.
  16293. */
  16294. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16295. }
  16296. interface Mesh {
  16297. /**
  16298. * Register a custom buffer that will be instanced
  16299. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16300. * @param kind defines the buffer kind
  16301. * @param stride defines the stride in floats
  16302. */
  16303. registerInstancedBuffer(kind: string, stride: number): void;
  16304. /** @hidden */
  16305. _userInstancedBuffersStorage: {
  16306. data: {
  16307. [key: string]: Float32Array;
  16308. };
  16309. sizes: {
  16310. [key: string]: number;
  16311. };
  16312. vertexBuffers: {
  16313. [key: string]: Nullable<VertexBuffer>;
  16314. };
  16315. strides: {
  16316. [key: string]: number;
  16317. };
  16318. };
  16319. }
  16320. interface AbstractMesh {
  16321. /**
  16322. * Object used to store instanced buffers defined by user
  16323. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16324. */
  16325. instancedBuffers: {
  16326. [key: string]: any;
  16327. };
  16328. }
  16329. }
  16330. declare module BABYLON {
  16331. /**
  16332. * Defines the options associated with the creation of a shader material.
  16333. */
  16334. export interface IShaderMaterialOptions {
  16335. /**
  16336. * Does the material work in alpha blend mode
  16337. */
  16338. needAlphaBlending: boolean;
  16339. /**
  16340. * Does the material work in alpha test mode
  16341. */
  16342. needAlphaTesting: boolean;
  16343. /**
  16344. * The list of attribute names used in the shader
  16345. */
  16346. attributes: string[];
  16347. /**
  16348. * The list of unifrom names used in the shader
  16349. */
  16350. uniforms: string[];
  16351. /**
  16352. * The list of UBO names used in the shader
  16353. */
  16354. uniformBuffers: string[];
  16355. /**
  16356. * The list of sampler names used in the shader
  16357. */
  16358. samplers: string[];
  16359. /**
  16360. * The list of defines used in the shader
  16361. */
  16362. defines: string[];
  16363. }
  16364. /**
  16365. * 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.
  16366. *
  16367. * This returned material effects how the mesh will look based on the code in the shaders.
  16368. *
  16369. * @see http://doc.babylonjs.com/how_to/shader_material
  16370. */
  16371. export class ShaderMaterial extends Material {
  16372. private _shaderPath;
  16373. private _options;
  16374. private _textures;
  16375. private _textureArrays;
  16376. private _floats;
  16377. private _ints;
  16378. private _floatsArrays;
  16379. private _colors3;
  16380. private _colors3Arrays;
  16381. private _colors4;
  16382. private _colors4Arrays;
  16383. private _vectors2;
  16384. private _vectors3;
  16385. private _vectors4;
  16386. private _matrices;
  16387. private _matrixArrays;
  16388. private _matrices3x3;
  16389. private _matrices2x2;
  16390. private _vectors2Arrays;
  16391. private _vectors3Arrays;
  16392. private _vectors4Arrays;
  16393. private _cachedWorldViewMatrix;
  16394. private _cachedWorldViewProjectionMatrix;
  16395. private _renderId;
  16396. private _multiview;
  16397. private _cachedDefines;
  16398. /**
  16399. * Instantiate a new shader material.
  16400. * 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.
  16401. * This returned material effects how the mesh will look based on the code in the shaders.
  16402. * @see http://doc.babylonjs.com/how_to/shader_material
  16403. * @param name Define the name of the material in the scene
  16404. * @param scene Define the scene the material belongs to
  16405. * @param shaderPath Defines the route to the shader code in one of three ways:
  16406. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16407. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16408. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16409. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16410. * @param options Define the options used to create the shader
  16411. */
  16412. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16413. /**
  16414. * Gets the shader path used to define the shader code
  16415. * It can be modified to trigger a new compilation
  16416. */
  16417. get shaderPath(): any;
  16418. /**
  16419. * Sets the shader path used to define the shader code
  16420. * It can be modified to trigger a new compilation
  16421. */
  16422. set shaderPath(shaderPath: any);
  16423. /**
  16424. * Gets the options used to compile the shader.
  16425. * They can be modified to trigger a new compilation
  16426. */
  16427. get options(): IShaderMaterialOptions;
  16428. /**
  16429. * Gets the current class name of the material e.g. "ShaderMaterial"
  16430. * Mainly use in serialization.
  16431. * @returns the class name
  16432. */
  16433. getClassName(): string;
  16434. /**
  16435. * Specifies if the material will require alpha blending
  16436. * @returns a boolean specifying if alpha blending is needed
  16437. */
  16438. needAlphaBlending(): boolean;
  16439. /**
  16440. * Specifies if this material should be rendered in alpha test mode
  16441. * @returns a boolean specifying if an alpha test is needed.
  16442. */
  16443. needAlphaTesting(): boolean;
  16444. private _checkUniform;
  16445. /**
  16446. * Set a texture in the shader.
  16447. * @param name Define the name of the uniform samplers as defined in the shader
  16448. * @param texture Define the texture to bind to this sampler
  16449. * @return the material itself allowing "fluent" like uniform updates
  16450. */
  16451. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16452. /**
  16453. * Set a texture array in the shader.
  16454. * @param name Define the name of the uniform sampler array as defined in the shader
  16455. * @param textures Define the list of textures to bind to this sampler
  16456. * @return the material itself allowing "fluent" like uniform updates
  16457. */
  16458. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16459. /**
  16460. * Set a float in the shader.
  16461. * @param name Define the name of the uniform as defined in the shader
  16462. * @param value Define the value to give to the uniform
  16463. * @return the material itself allowing "fluent" like uniform updates
  16464. */
  16465. setFloat(name: string, value: number): ShaderMaterial;
  16466. /**
  16467. * Set a int in the shader.
  16468. * @param name Define the name of the uniform as defined in the shader
  16469. * @param value Define the value to give to the uniform
  16470. * @return the material itself allowing "fluent" like uniform updates
  16471. */
  16472. setInt(name: string, value: number): ShaderMaterial;
  16473. /**
  16474. * Set an array of floats in the shader.
  16475. * @param name Define the name of the uniform as defined in the shader
  16476. * @param value Define the value to give to the uniform
  16477. * @return the material itself allowing "fluent" like uniform updates
  16478. */
  16479. setFloats(name: string, value: number[]): ShaderMaterial;
  16480. /**
  16481. * Set a vec3 in the shader from a Color3.
  16482. * @param name Define the name of the uniform as defined in the shader
  16483. * @param value Define the value to give to the uniform
  16484. * @return the material itself allowing "fluent" like uniform updates
  16485. */
  16486. setColor3(name: string, value: Color3): ShaderMaterial;
  16487. /**
  16488. * Set a vec3 array in the shader from a Color3 array.
  16489. * @param name Define the name of the uniform as defined in the shader
  16490. * @param value Define the value to give to the uniform
  16491. * @return the material itself allowing "fluent" like uniform updates
  16492. */
  16493. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16494. /**
  16495. * Set a vec4 in the shader from a Color4.
  16496. * @param name Define the name of the uniform as defined in the shader
  16497. * @param value Define the value to give to the uniform
  16498. * @return the material itself allowing "fluent" like uniform updates
  16499. */
  16500. setColor4(name: string, value: Color4): ShaderMaterial;
  16501. /**
  16502. * Set a vec4 array in the shader from a Color4 array.
  16503. * @param name Define the name of the uniform as defined in the shader
  16504. * @param value Define the value to give to the uniform
  16505. * @return the material itself allowing "fluent" like uniform updates
  16506. */
  16507. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16508. /**
  16509. * Set a vec2 in the shader from a Vector2.
  16510. * @param name Define the name of the uniform as defined in the shader
  16511. * @param value Define the value to give to the uniform
  16512. * @return the material itself allowing "fluent" like uniform updates
  16513. */
  16514. setVector2(name: string, value: Vector2): ShaderMaterial;
  16515. /**
  16516. * Set a vec3 in the shader from a Vector3.
  16517. * @param name Define the name of the uniform as defined in the shader
  16518. * @param value Define the value to give to the uniform
  16519. * @return the material itself allowing "fluent" like uniform updates
  16520. */
  16521. setVector3(name: string, value: Vector3): ShaderMaterial;
  16522. /**
  16523. * Set a vec4 in the shader from a Vector4.
  16524. * @param name Define the name of the uniform as defined in the shader
  16525. * @param value Define the value to give to the uniform
  16526. * @return the material itself allowing "fluent" like uniform updates
  16527. */
  16528. setVector4(name: string, value: Vector4): ShaderMaterial;
  16529. /**
  16530. * Set a mat4 in the shader from a Matrix.
  16531. * @param name Define the name of the uniform as defined in the shader
  16532. * @param value Define the value to give to the uniform
  16533. * @return the material itself allowing "fluent" like uniform updates
  16534. */
  16535. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16536. /**
  16537. * Set a float32Array in the shader from a matrix array.
  16538. * @param name Define the name of the uniform as defined in the shader
  16539. * @param value Define the value to give to the uniform
  16540. * @return the material itself allowing "fluent" like uniform updates
  16541. */
  16542. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16543. /**
  16544. * Set a mat3 in the shader from a Float32Array.
  16545. * @param name Define the name of the uniform as defined in the shader
  16546. * @param value Define the value to give to the uniform
  16547. * @return the material itself allowing "fluent" like uniform updates
  16548. */
  16549. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16550. /**
  16551. * Set a mat2 in the shader from a Float32Array.
  16552. * @param name Define the name of the uniform as defined in the shader
  16553. * @param value Define the value to give to the uniform
  16554. * @return the material itself allowing "fluent" like uniform updates
  16555. */
  16556. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16557. /**
  16558. * Set a vec2 array in the shader from a number array.
  16559. * @param name Define the name of the uniform as defined in the shader
  16560. * @param value Define the value to give to the uniform
  16561. * @return the material itself allowing "fluent" like uniform updates
  16562. */
  16563. setArray2(name: string, value: number[]): ShaderMaterial;
  16564. /**
  16565. * Set a vec3 array in the shader from a number array.
  16566. * @param name Define the name of the uniform as defined in the shader
  16567. * @param value Define the value to give to the uniform
  16568. * @return the material itself allowing "fluent" like uniform updates
  16569. */
  16570. setArray3(name: string, value: number[]): ShaderMaterial;
  16571. /**
  16572. * Set a vec4 array in the shader from a number array.
  16573. * @param name Define the name of the uniform as defined in the shader
  16574. * @param value Define the value to give to the uniform
  16575. * @return the material itself allowing "fluent" like uniform updates
  16576. */
  16577. setArray4(name: string, value: number[]): ShaderMaterial;
  16578. private _checkCache;
  16579. /**
  16580. * Specifies that the submesh is ready to be used
  16581. * @param mesh defines the mesh to check
  16582. * @param subMesh defines which submesh to check
  16583. * @param useInstances specifies that instances should be used
  16584. * @returns a boolean indicating that the submesh is ready or not
  16585. */
  16586. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16587. /**
  16588. * Checks if the material is ready to render the requested mesh
  16589. * @param mesh Define the mesh to render
  16590. * @param useInstances Define whether or not the material is used with instances
  16591. * @returns true if ready, otherwise false
  16592. */
  16593. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16594. /**
  16595. * Binds the world matrix to the material
  16596. * @param world defines the world transformation matrix
  16597. * @param effectOverride - If provided, use this effect instead of internal effect
  16598. */
  16599. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16600. /**
  16601. * Binds the submesh to this material by preparing the effect and shader to draw
  16602. * @param world defines the world transformation matrix
  16603. * @param mesh defines the mesh containing the submesh
  16604. * @param subMesh defines the submesh to bind the material to
  16605. */
  16606. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16607. /**
  16608. * Binds the material to the mesh
  16609. * @param world defines the world transformation matrix
  16610. * @param mesh defines the mesh to bind the material to
  16611. * @param effectOverride - If provided, use this effect instead of internal effect
  16612. */
  16613. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16614. protected _afterBind(mesh?: Mesh): void;
  16615. /**
  16616. * Gets the active textures from the material
  16617. * @returns an array of textures
  16618. */
  16619. getActiveTextures(): BaseTexture[];
  16620. /**
  16621. * Specifies if the material uses a texture
  16622. * @param texture defines the texture to check against the material
  16623. * @returns a boolean specifying if the material uses the texture
  16624. */
  16625. hasTexture(texture: BaseTexture): boolean;
  16626. /**
  16627. * Makes a duplicate of the material, and gives it a new name
  16628. * @param name defines the new name for the duplicated material
  16629. * @returns the cloned material
  16630. */
  16631. clone(name: string): ShaderMaterial;
  16632. /**
  16633. * Disposes the material
  16634. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16635. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16636. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16637. */
  16638. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16639. /**
  16640. * Serializes this material in a JSON representation
  16641. * @returns the serialized material object
  16642. */
  16643. serialize(): any;
  16644. /**
  16645. * Creates a shader material from parsed shader material data
  16646. * @param source defines the JSON represnetation of the material
  16647. * @param scene defines the hosting scene
  16648. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16649. * @returns a new material
  16650. */
  16651. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16652. }
  16653. }
  16654. declare module BABYLON {
  16655. /** @hidden */
  16656. export var colorPixelShader: {
  16657. name: string;
  16658. shader: string;
  16659. };
  16660. }
  16661. declare module BABYLON {
  16662. /** @hidden */
  16663. export var colorVertexShader: {
  16664. name: string;
  16665. shader: string;
  16666. };
  16667. }
  16668. declare module BABYLON {
  16669. /**
  16670. * Line mesh
  16671. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16672. */
  16673. export class LinesMesh extends Mesh {
  16674. /**
  16675. * If vertex color should be applied to the mesh
  16676. */
  16677. readonly useVertexColor?: boolean | undefined;
  16678. /**
  16679. * If vertex alpha should be applied to the mesh
  16680. */
  16681. readonly useVertexAlpha?: boolean | undefined;
  16682. /**
  16683. * Color of the line (Default: White)
  16684. */
  16685. color: Color3;
  16686. /**
  16687. * Alpha of the line (Default: 1)
  16688. */
  16689. alpha: number;
  16690. /**
  16691. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16692. * This margin is expressed in world space coordinates, so its value may vary.
  16693. * Default value is 0.1
  16694. */
  16695. intersectionThreshold: number;
  16696. private _colorShader;
  16697. private color4;
  16698. /**
  16699. * Creates a new LinesMesh
  16700. * @param name defines the name
  16701. * @param scene defines the hosting scene
  16702. * @param parent defines the parent mesh if any
  16703. * @param source defines the optional source LinesMesh used to clone data from
  16704. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16705. * When false, achieved by calling a clone(), also passing False.
  16706. * This will make creation of children, recursive.
  16707. * @param useVertexColor defines if this LinesMesh supports vertex color
  16708. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16709. */
  16710. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16711. /**
  16712. * If vertex color should be applied to the mesh
  16713. */
  16714. useVertexColor?: boolean | undefined,
  16715. /**
  16716. * If vertex alpha should be applied to the mesh
  16717. */
  16718. useVertexAlpha?: boolean | undefined);
  16719. private _addClipPlaneDefine;
  16720. private _removeClipPlaneDefine;
  16721. isReady(): boolean;
  16722. /**
  16723. * Returns the string "LineMesh"
  16724. */
  16725. getClassName(): string;
  16726. /**
  16727. * @hidden
  16728. */
  16729. get material(): Material;
  16730. /**
  16731. * @hidden
  16732. */
  16733. set material(value: Material);
  16734. /**
  16735. * @hidden
  16736. */
  16737. get checkCollisions(): boolean;
  16738. /** @hidden */
  16739. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16740. /** @hidden */
  16741. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16742. /**
  16743. * Disposes of the line mesh
  16744. * @param doNotRecurse If children should be disposed
  16745. */
  16746. dispose(doNotRecurse?: boolean): void;
  16747. /**
  16748. * Returns a new LineMesh object cloned from the current one.
  16749. */
  16750. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16751. /**
  16752. * Creates a new InstancedLinesMesh object from the mesh model.
  16753. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16754. * @param name defines the name of the new instance
  16755. * @returns a new InstancedLinesMesh
  16756. */
  16757. createInstance(name: string): InstancedLinesMesh;
  16758. }
  16759. /**
  16760. * Creates an instance based on a source LinesMesh
  16761. */
  16762. export class InstancedLinesMesh extends InstancedMesh {
  16763. /**
  16764. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16765. * This margin is expressed in world space coordinates, so its value may vary.
  16766. * Initilized with the intersectionThreshold value of the source LinesMesh
  16767. */
  16768. intersectionThreshold: number;
  16769. constructor(name: string, source: LinesMesh);
  16770. /**
  16771. * Returns the string "InstancedLinesMesh".
  16772. */
  16773. getClassName(): string;
  16774. }
  16775. }
  16776. declare module BABYLON {
  16777. /** @hidden */
  16778. export var linePixelShader: {
  16779. name: string;
  16780. shader: string;
  16781. };
  16782. }
  16783. declare module BABYLON {
  16784. /** @hidden */
  16785. export var lineVertexShader: {
  16786. name: string;
  16787. shader: string;
  16788. };
  16789. }
  16790. declare module BABYLON {
  16791. interface AbstractMesh {
  16792. /**
  16793. * Gets the edgesRenderer associated with the mesh
  16794. */
  16795. edgesRenderer: Nullable<EdgesRenderer>;
  16796. }
  16797. interface LinesMesh {
  16798. /**
  16799. * Enables the edge rendering mode on the mesh.
  16800. * This mode makes the mesh edges visible
  16801. * @param epsilon defines the maximal distance between two angles to detect a face
  16802. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16803. * @returns the currentAbstractMesh
  16804. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16805. */
  16806. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16807. }
  16808. interface InstancedLinesMesh {
  16809. /**
  16810. * Enables the edge rendering mode on the mesh.
  16811. * This mode makes the mesh edges visible
  16812. * @param epsilon defines the maximal distance between two angles to detect a face
  16813. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16814. * @returns the current InstancedLinesMesh
  16815. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16816. */
  16817. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16818. }
  16819. /**
  16820. * Defines the minimum contract an Edges renderer should follow.
  16821. */
  16822. export interface IEdgesRenderer extends IDisposable {
  16823. /**
  16824. * Gets or sets a boolean indicating if the edgesRenderer is active
  16825. */
  16826. isEnabled: boolean;
  16827. /**
  16828. * Renders the edges of the attached mesh,
  16829. */
  16830. render(): void;
  16831. /**
  16832. * Checks wether or not the edges renderer is ready to render.
  16833. * @return true if ready, otherwise false.
  16834. */
  16835. isReady(): boolean;
  16836. }
  16837. /**
  16838. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16839. */
  16840. export class EdgesRenderer implements IEdgesRenderer {
  16841. /**
  16842. * Define the size of the edges with an orthographic camera
  16843. */
  16844. edgesWidthScalerForOrthographic: number;
  16845. /**
  16846. * Define the size of the edges with a perspective camera
  16847. */
  16848. edgesWidthScalerForPerspective: number;
  16849. protected _source: AbstractMesh;
  16850. protected _linesPositions: number[];
  16851. protected _linesNormals: number[];
  16852. protected _linesIndices: number[];
  16853. protected _epsilon: number;
  16854. protected _indicesCount: number;
  16855. protected _lineShader: ShaderMaterial;
  16856. protected _ib: DataBuffer;
  16857. protected _buffers: {
  16858. [key: string]: Nullable<VertexBuffer>;
  16859. };
  16860. protected _checkVerticesInsteadOfIndices: boolean;
  16861. private _meshRebuildObserver;
  16862. private _meshDisposeObserver;
  16863. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16864. isEnabled: boolean;
  16865. /**
  16866. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16867. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16868. * @param source Mesh used to create edges
  16869. * @param epsilon sum of angles in adjacency to check for edge
  16870. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16871. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16872. */
  16873. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16874. protected _prepareRessources(): void;
  16875. /** @hidden */
  16876. _rebuild(): void;
  16877. /**
  16878. * Releases the required resources for the edges renderer
  16879. */
  16880. dispose(): void;
  16881. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16882. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16883. /**
  16884. * Checks if the pair of p0 and p1 is en edge
  16885. * @param faceIndex
  16886. * @param edge
  16887. * @param faceNormals
  16888. * @param p0
  16889. * @param p1
  16890. * @private
  16891. */
  16892. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16893. /**
  16894. * push line into the position, normal and index buffer
  16895. * @protected
  16896. */
  16897. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16898. /**
  16899. * Generates lines edges from adjacencjes
  16900. * @private
  16901. */
  16902. _generateEdgesLines(): void;
  16903. /**
  16904. * Checks wether or not the edges renderer is ready to render.
  16905. * @return true if ready, otherwise false.
  16906. */
  16907. isReady(): boolean;
  16908. /**
  16909. * Renders the edges of the attached mesh,
  16910. */
  16911. render(): void;
  16912. }
  16913. /**
  16914. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16915. */
  16916. export class LineEdgesRenderer extends EdgesRenderer {
  16917. /**
  16918. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16919. * @param source LineMesh used to generate edges
  16920. * @param epsilon not important (specified angle for edge detection)
  16921. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16922. */
  16923. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16924. /**
  16925. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16926. */
  16927. _generateEdgesLines(): void;
  16928. }
  16929. }
  16930. declare module BABYLON {
  16931. /**
  16932. * This represents the object necessary to create a rendering group.
  16933. * This is exclusively used and created by the rendering manager.
  16934. * To modify the behavior, you use the available helpers in your scene or meshes.
  16935. * @hidden
  16936. */
  16937. export class RenderingGroup {
  16938. index: number;
  16939. private static _zeroVector;
  16940. private _scene;
  16941. private _opaqueSubMeshes;
  16942. private _transparentSubMeshes;
  16943. private _alphaTestSubMeshes;
  16944. private _depthOnlySubMeshes;
  16945. private _particleSystems;
  16946. private _spriteManagers;
  16947. private _opaqueSortCompareFn;
  16948. private _alphaTestSortCompareFn;
  16949. private _transparentSortCompareFn;
  16950. private _renderOpaque;
  16951. private _renderAlphaTest;
  16952. private _renderTransparent;
  16953. /** @hidden */
  16954. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16955. onBeforeTransparentRendering: () => void;
  16956. /**
  16957. * Set the opaque sort comparison function.
  16958. * If null the sub meshes will be render in the order they were created
  16959. */
  16960. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16961. /**
  16962. * Set the alpha test sort comparison function.
  16963. * If null the sub meshes will be render in the order they were created
  16964. */
  16965. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16966. /**
  16967. * Set the transparent sort comparison function.
  16968. * If null the sub meshes will be render in the order they were created
  16969. */
  16970. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16971. /**
  16972. * Creates a new rendering group.
  16973. * @param index The rendering group index
  16974. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16975. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16976. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16977. */
  16978. 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>);
  16979. /**
  16980. * Render all the sub meshes contained in the group.
  16981. * @param customRenderFunction Used to override the default render behaviour of the group.
  16982. * @returns true if rendered some submeshes.
  16983. */
  16984. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16985. /**
  16986. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16987. * @param subMeshes The submeshes to render
  16988. */
  16989. private renderOpaqueSorted;
  16990. /**
  16991. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16992. * @param subMeshes The submeshes to render
  16993. */
  16994. private renderAlphaTestSorted;
  16995. /**
  16996. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16997. * @param subMeshes The submeshes to render
  16998. */
  16999. private renderTransparentSorted;
  17000. /**
  17001. * Renders the submeshes in a specified order.
  17002. * @param subMeshes The submeshes to sort before render
  17003. * @param sortCompareFn The comparison function use to sort
  17004. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17005. * @param transparent Specifies to activate blending if true
  17006. */
  17007. private static renderSorted;
  17008. /**
  17009. * Renders the submeshes in the order they were dispatched (no sort applied).
  17010. * @param subMeshes The submeshes to render
  17011. */
  17012. private static renderUnsorted;
  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 if in the same alpha index.
  17016. *
  17017. * @param a The first submesh
  17018. * @param b The second submesh
  17019. * @returns The result of the comparison
  17020. */
  17021. static defaultTransparentSortCompare(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 back to front.
  17025. *
  17026. * @param a The first submesh
  17027. * @param b The second submesh
  17028. * @returns The result of the comparison
  17029. */
  17030. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17031. /**
  17032. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17033. * are rendered front to back (prevent overdraw).
  17034. *
  17035. * @param a The first submesh
  17036. * @param b The second submesh
  17037. * @returns The result of the comparison
  17038. */
  17039. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17040. /**
  17041. * Resets the different lists of submeshes to prepare a new frame.
  17042. */
  17043. prepare(): void;
  17044. dispose(): void;
  17045. /**
  17046. * Inserts the submesh in its correct queue depending on its material.
  17047. * @param subMesh The submesh to dispatch
  17048. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17049. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17050. */
  17051. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17052. dispatchSprites(spriteManager: ISpriteManager): void;
  17053. dispatchParticles(particleSystem: IParticleSystem): void;
  17054. private _renderParticles;
  17055. private _renderSprites;
  17056. }
  17057. }
  17058. declare module BABYLON {
  17059. /**
  17060. * Interface describing the different options available in the rendering manager
  17061. * regarding Auto Clear between groups.
  17062. */
  17063. export interface IRenderingManagerAutoClearSetup {
  17064. /**
  17065. * Defines whether or not autoclear is enable.
  17066. */
  17067. autoClear: boolean;
  17068. /**
  17069. * Defines whether or not to autoclear the depth buffer.
  17070. */
  17071. depth: boolean;
  17072. /**
  17073. * Defines whether or not to autoclear the stencil buffer.
  17074. */
  17075. stencil: boolean;
  17076. }
  17077. /**
  17078. * This class is used by the onRenderingGroupObservable
  17079. */
  17080. export class RenderingGroupInfo {
  17081. /**
  17082. * The Scene that being rendered
  17083. */
  17084. scene: Scene;
  17085. /**
  17086. * The camera currently used for the rendering pass
  17087. */
  17088. camera: Nullable<Camera>;
  17089. /**
  17090. * The ID of the renderingGroup being processed
  17091. */
  17092. renderingGroupId: number;
  17093. }
  17094. /**
  17095. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17096. * It is enable to manage the different groups as well as the different necessary sort functions.
  17097. * This should not be used directly aside of the few static configurations
  17098. */
  17099. export class RenderingManager {
  17100. /**
  17101. * The max id used for rendering groups (not included)
  17102. */
  17103. static MAX_RENDERINGGROUPS: number;
  17104. /**
  17105. * The min id used for rendering groups (included)
  17106. */
  17107. static MIN_RENDERINGGROUPS: number;
  17108. /**
  17109. * Used to globally prevent autoclearing scenes.
  17110. */
  17111. static AUTOCLEAR: boolean;
  17112. /**
  17113. * @hidden
  17114. */
  17115. _useSceneAutoClearSetup: boolean;
  17116. private _scene;
  17117. private _renderingGroups;
  17118. private _depthStencilBufferAlreadyCleaned;
  17119. private _autoClearDepthStencil;
  17120. private _customOpaqueSortCompareFn;
  17121. private _customAlphaTestSortCompareFn;
  17122. private _customTransparentSortCompareFn;
  17123. private _renderingGroupInfo;
  17124. /**
  17125. * Instantiates a new rendering group for a particular scene
  17126. * @param scene Defines the scene the groups belongs to
  17127. */
  17128. constructor(scene: Scene);
  17129. private _clearDepthStencilBuffer;
  17130. /**
  17131. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17132. * @hidden
  17133. */
  17134. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17135. /**
  17136. * Resets the different information of the group to prepare a new frame
  17137. * @hidden
  17138. */
  17139. reset(): void;
  17140. /**
  17141. * Dispose and release the group and its associated resources.
  17142. * @hidden
  17143. */
  17144. dispose(): void;
  17145. /**
  17146. * Clear the info related to rendering groups preventing retention points during dispose.
  17147. */
  17148. freeRenderingGroups(): void;
  17149. private _prepareRenderingGroup;
  17150. /**
  17151. * Add a sprite manager to the rendering manager in order to render it this frame.
  17152. * @param spriteManager Define the sprite manager to render
  17153. */
  17154. dispatchSprites(spriteManager: ISpriteManager): void;
  17155. /**
  17156. * Add a particle system to the rendering manager in order to render it this frame.
  17157. * @param particleSystem Define the particle system to render
  17158. */
  17159. dispatchParticles(particleSystem: IParticleSystem): void;
  17160. /**
  17161. * Add a submesh to the manager in order to render it this frame
  17162. * @param subMesh The submesh to dispatch
  17163. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17164. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17165. */
  17166. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17167. /**
  17168. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17169. * This allowed control for front to back rendering or reversly depending of the special needs.
  17170. *
  17171. * @param renderingGroupId The rendering group id corresponding to its index
  17172. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17173. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17174. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17175. */
  17176. 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;
  17177. /**
  17178. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17179. *
  17180. * @param renderingGroupId The rendering group id corresponding to its index
  17181. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17182. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17183. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17184. */
  17185. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17186. /**
  17187. * Gets the current auto clear configuration for one rendering group of the rendering
  17188. * manager.
  17189. * @param index the rendering group index to get the information for
  17190. * @returns The auto clear setup for the requested rendering group
  17191. */
  17192. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17193. }
  17194. }
  17195. declare module BABYLON {
  17196. /**
  17197. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17198. */
  17199. export interface ICustomShaderOptions {
  17200. /**
  17201. * Gets or sets the custom shader name to use
  17202. */
  17203. shaderName: string;
  17204. /**
  17205. * The list of attribute names used in the shader
  17206. */
  17207. attributes?: string[];
  17208. /**
  17209. * The list of unifrom names used in the shader
  17210. */
  17211. uniforms?: string[];
  17212. /**
  17213. * The list of sampler names used in the shader
  17214. */
  17215. samplers?: string[];
  17216. /**
  17217. * The list of defines used in the shader
  17218. */
  17219. defines?: string[];
  17220. }
  17221. /**
  17222. * Interface to implement to create a shadow generator compatible with BJS.
  17223. */
  17224. export interface IShadowGenerator {
  17225. /**
  17226. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17227. * @returns The render target texture if present otherwise, null
  17228. */
  17229. getShadowMap(): Nullable<RenderTargetTexture>;
  17230. /**
  17231. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17232. * @param subMesh The submesh we want to render in the shadow map
  17233. * @param useInstances Defines wether will draw in the map using instances
  17234. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17235. * @returns true if ready otherwise, false
  17236. */
  17237. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17238. /**
  17239. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17240. * @param defines Defines of the material we want to update
  17241. * @param lightIndex Index of the light in the enabled light list of the material
  17242. */
  17243. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17244. /**
  17245. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17246. * defined in the generator but impacting the effect).
  17247. * It implies the unifroms available on the materials are the standard BJS ones.
  17248. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17249. * @param effect The effect we are binfing the information for
  17250. */
  17251. bindShadowLight(lightIndex: string, effect: Effect): void;
  17252. /**
  17253. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17254. * (eq to shadow prjection matrix * light transform matrix)
  17255. * @returns The transform matrix used to create the shadow map
  17256. */
  17257. getTransformMatrix(): Matrix;
  17258. /**
  17259. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17260. * Cube and 2D textures for instance.
  17261. */
  17262. recreateShadowMap(): void;
  17263. /**
  17264. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17265. * @param onCompiled Callback triggered at the and of the effects compilation
  17266. * @param options Sets of optional options forcing the compilation with different modes
  17267. */
  17268. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17269. useInstances: boolean;
  17270. }>): void;
  17271. /**
  17272. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17273. * @param options Sets of optional options forcing the compilation with different modes
  17274. * @returns A promise that resolves when the compilation completes
  17275. */
  17276. forceCompilationAsync(options?: Partial<{
  17277. useInstances: boolean;
  17278. }>): Promise<void>;
  17279. /**
  17280. * Serializes the shadow generator setup to a json object.
  17281. * @returns The serialized JSON object
  17282. */
  17283. serialize(): any;
  17284. /**
  17285. * Disposes the Shadow map and related Textures and effects.
  17286. */
  17287. dispose(): void;
  17288. }
  17289. /**
  17290. * Default implementation IShadowGenerator.
  17291. * This is the main object responsible of generating shadows in the framework.
  17292. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17293. */
  17294. export class ShadowGenerator implements IShadowGenerator {
  17295. /**
  17296. * Name of the shadow generator class
  17297. */
  17298. static CLASSNAME: string;
  17299. /**
  17300. * Shadow generator mode None: no filtering applied.
  17301. */
  17302. static readonly FILTER_NONE: number;
  17303. /**
  17304. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17305. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17306. */
  17307. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17308. /**
  17309. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17310. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17311. */
  17312. static readonly FILTER_POISSONSAMPLING: number;
  17313. /**
  17314. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17315. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17316. */
  17317. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17318. /**
  17319. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17320. * edge artifacts on steep falloff.
  17321. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17322. */
  17323. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17324. /**
  17325. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17326. * edge artifacts on steep falloff.
  17327. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17328. */
  17329. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17330. /**
  17331. * Shadow generator mode PCF: Percentage Closer Filtering
  17332. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17333. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17334. */
  17335. static readonly FILTER_PCF: number;
  17336. /**
  17337. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17338. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17339. * Contact Hardening
  17340. */
  17341. static readonly FILTER_PCSS: number;
  17342. /**
  17343. * Reserved for PCF and PCSS
  17344. * Highest Quality.
  17345. *
  17346. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17347. *
  17348. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17349. */
  17350. static readonly QUALITY_HIGH: number;
  17351. /**
  17352. * Reserved for PCF and PCSS
  17353. * Good tradeoff for quality/perf cross devices
  17354. *
  17355. * Execute PCF on a 3*3 kernel.
  17356. *
  17357. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17358. */
  17359. static readonly QUALITY_MEDIUM: number;
  17360. /**
  17361. * Reserved for PCF and PCSS
  17362. * The lowest quality but the fastest.
  17363. *
  17364. * Execute PCF on a 1*1 kernel.
  17365. *
  17366. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17367. */
  17368. static readonly QUALITY_LOW: number;
  17369. /** Gets or sets the custom shader name to use */
  17370. customShaderOptions: ICustomShaderOptions;
  17371. /**
  17372. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17373. */
  17374. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17375. /**
  17376. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17377. */
  17378. onAfterShadowMapRenderObservable: Observable<Effect>;
  17379. /**
  17380. * Observable triggered before a mesh is rendered in the shadow map.
  17381. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17382. */
  17383. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17384. /**
  17385. * Observable triggered after a mesh is rendered in the shadow map.
  17386. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17387. */
  17388. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17389. protected _bias: number;
  17390. /**
  17391. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17392. */
  17393. get bias(): number;
  17394. /**
  17395. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17396. */
  17397. set bias(bias: number);
  17398. protected _normalBias: number;
  17399. /**
  17400. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17401. */
  17402. get normalBias(): number;
  17403. /**
  17404. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17405. */
  17406. set normalBias(normalBias: number);
  17407. protected _blurBoxOffset: number;
  17408. /**
  17409. * Gets the blur box offset: offset applied during the blur pass.
  17410. * Only useful if useKernelBlur = false
  17411. */
  17412. get blurBoxOffset(): number;
  17413. /**
  17414. * Sets the blur box offset: offset applied during the blur pass.
  17415. * Only useful if useKernelBlur = false
  17416. */
  17417. set blurBoxOffset(value: number);
  17418. protected _blurScale: number;
  17419. /**
  17420. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17421. * 2 means half of the size.
  17422. */
  17423. get blurScale(): number;
  17424. /**
  17425. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17426. * 2 means half of the size.
  17427. */
  17428. set blurScale(value: number);
  17429. protected _blurKernel: number;
  17430. /**
  17431. * Gets the blur kernel: kernel size of the blur pass.
  17432. * Only useful if useKernelBlur = true
  17433. */
  17434. get blurKernel(): number;
  17435. /**
  17436. * Sets the blur kernel: kernel size of the blur pass.
  17437. * Only useful if useKernelBlur = true
  17438. */
  17439. set blurKernel(value: number);
  17440. protected _useKernelBlur: boolean;
  17441. /**
  17442. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17443. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17444. */
  17445. get useKernelBlur(): boolean;
  17446. /**
  17447. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17448. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17449. */
  17450. set useKernelBlur(value: boolean);
  17451. protected _depthScale: number;
  17452. /**
  17453. * Gets the depth scale used in ESM mode.
  17454. */
  17455. get depthScale(): number;
  17456. /**
  17457. * Sets the depth scale used in ESM mode.
  17458. * This can override the scale stored on the light.
  17459. */
  17460. set depthScale(value: number);
  17461. protected _validateFilter(filter: number): number;
  17462. protected _filter: number;
  17463. /**
  17464. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17465. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17466. */
  17467. get filter(): number;
  17468. /**
  17469. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17470. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17471. */
  17472. set filter(value: number);
  17473. /**
  17474. * Gets if the current filter is set to Poisson Sampling.
  17475. */
  17476. get usePoissonSampling(): boolean;
  17477. /**
  17478. * Sets the current filter to Poisson Sampling.
  17479. */
  17480. set usePoissonSampling(value: boolean);
  17481. /**
  17482. * Gets if the current filter is set to ESM.
  17483. */
  17484. get useExponentialShadowMap(): boolean;
  17485. /**
  17486. * Sets the current filter is to ESM.
  17487. */
  17488. set useExponentialShadowMap(value: boolean);
  17489. /**
  17490. * Gets if the current filter is set to filtered ESM.
  17491. */
  17492. get useBlurExponentialShadowMap(): boolean;
  17493. /**
  17494. * Gets if the current filter is set to filtered ESM.
  17495. */
  17496. set useBlurExponentialShadowMap(value: boolean);
  17497. /**
  17498. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17499. * exponential to prevent steep falloff artifacts).
  17500. */
  17501. get useCloseExponentialShadowMap(): boolean;
  17502. /**
  17503. * Sets the current filter to "close ESM" (using the inverse of the
  17504. * exponential to prevent steep falloff artifacts).
  17505. */
  17506. set useCloseExponentialShadowMap(value: boolean);
  17507. /**
  17508. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17509. * exponential to prevent steep falloff artifacts).
  17510. */
  17511. get useBlurCloseExponentialShadowMap(): boolean;
  17512. /**
  17513. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17514. * exponential to prevent steep falloff artifacts).
  17515. */
  17516. set useBlurCloseExponentialShadowMap(value: boolean);
  17517. /**
  17518. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17519. */
  17520. get usePercentageCloserFiltering(): boolean;
  17521. /**
  17522. * Sets the current filter to "PCF" (percentage closer filtering).
  17523. */
  17524. set usePercentageCloserFiltering(value: boolean);
  17525. protected _filteringQuality: number;
  17526. /**
  17527. * Gets the PCF or PCSS Quality.
  17528. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17529. */
  17530. get filteringQuality(): number;
  17531. /**
  17532. * Sets the PCF or PCSS Quality.
  17533. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17534. */
  17535. set filteringQuality(filteringQuality: number);
  17536. /**
  17537. * Gets if the current filter is set to "PCSS" (contact hardening).
  17538. */
  17539. get useContactHardeningShadow(): boolean;
  17540. /**
  17541. * Sets the current filter to "PCSS" (contact hardening).
  17542. */
  17543. set useContactHardeningShadow(value: boolean);
  17544. protected _contactHardeningLightSizeUVRatio: number;
  17545. /**
  17546. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17547. * Using a ratio helps keeping shape stability independently of the map size.
  17548. *
  17549. * It does not account for the light projection as it was having too much
  17550. * instability during the light setup or during light position changes.
  17551. *
  17552. * Only valid if useContactHardeningShadow is true.
  17553. */
  17554. get contactHardeningLightSizeUVRatio(): number;
  17555. /**
  17556. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17557. * Using a ratio helps keeping shape stability independently of the map size.
  17558. *
  17559. * It does not account for the light projection as it was having too much
  17560. * instability during the light setup or during light position changes.
  17561. *
  17562. * Only valid if useContactHardeningShadow is true.
  17563. */
  17564. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17565. protected _darkness: number;
  17566. /** Gets or sets the actual darkness of a shadow */
  17567. get darkness(): number;
  17568. set darkness(value: number);
  17569. /**
  17570. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17571. * 0 means strongest and 1 would means no shadow.
  17572. * @returns the darkness.
  17573. */
  17574. getDarkness(): number;
  17575. /**
  17576. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17577. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17578. * @returns the shadow generator allowing fluent coding.
  17579. */
  17580. setDarkness(darkness: number): ShadowGenerator;
  17581. protected _transparencyShadow: boolean;
  17582. /** Gets or sets the ability to have transparent shadow */
  17583. get transparencyShadow(): boolean;
  17584. set transparencyShadow(value: boolean);
  17585. /**
  17586. * Sets the ability to have transparent shadow (boolean).
  17587. * @param transparent True if transparent else False
  17588. * @returns the shadow generator allowing fluent coding
  17589. */
  17590. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17591. /**
  17592. * Enables or disables shadows with varying strength based on the transparency
  17593. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17594. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17595. * mesh.visibility * alphaTexture.a
  17596. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17597. */
  17598. enableSoftTransparentShadow: boolean;
  17599. protected _shadowMap: Nullable<RenderTargetTexture>;
  17600. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17601. /**
  17602. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17603. * @returns The render target texture if present otherwise, null
  17604. */
  17605. getShadowMap(): Nullable<RenderTargetTexture>;
  17606. /**
  17607. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17608. * @returns The render target texture if the shadow map is present otherwise, null
  17609. */
  17610. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17611. /**
  17612. * Gets the class name of that object
  17613. * @returns "ShadowGenerator"
  17614. */
  17615. getClassName(): string;
  17616. /**
  17617. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17618. * @param mesh Mesh to add
  17619. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17620. * @returns the Shadow Generator itself
  17621. */
  17622. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17623. /**
  17624. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17625. * @param mesh Mesh to remove
  17626. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17627. * @returns the Shadow Generator itself
  17628. */
  17629. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17630. /**
  17631. * Controls the extent to which the shadows fade out at the edge of the frustum
  17632. */
  17633. frustumEdgeFalloff: number;
  17634. protected _light: IShadowLight;
  17635. /**
  17636. * Returns the associated light object.
  17637. * @returns the light generating the shadow
  17638. */
  17639. getLight(): IShadowLight;
  17640. /**
  17641. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17642. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17643. * It might on the other hand introduce peter panning.
  17644. */
  17645. forceBackFacesOnly: boolean;
  17646. protected _scene: Scene;
  17647. protected _lightDirection: Vector3;
  17648. protected _effect: Effect;
  17649. protected _viewMatrix: Matrix;
  17650. protected _projectionMatrix: Matrix;
  17651. protected _transformMatrix: Matrix;
  17652. protected _cachedPosition: Vector3;
  17653. protected _cachedDirection: Vector3;
  17654. protected _cachedDefines: string;
  17655. protected _currentRenderID: number;
  17656. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17657. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17658. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17659. protected _blurPostProcesses: PostProcess[];
  17660. protected _mapSize: number;
  17661. protected _currentFaceIndex: number;
  17662. protected _currentFaceIndexCache: number;
  17663. protected _textureType: number;
  17664. protected _defaultTextureMatrix: Matrix;
  17665. protected _storedUniqueId: Nullable<number>;
  17666. /** @hidden */
  17667. static _SceneComponentInitialization: (scene: Scene) => void;
  17668. /**
  17669. * Creates a ShadowGenerator object.
  17670. * A ShadowGenerator is the required tool to use the shadows.
  17671. * Each light casting shadows needs to use its own ShadowGenerator.
  17672. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17673. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17674. * @param light The light object generating the shadows.
  17675. * @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.
  17676. */
  17677. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17678. protected _initializeGenerator(): void;
  17679. protected _createTargetRenderTexture(): void;
  17680. protected _initializeShadowMap(): void;
  17681. protected _initializeBlurRTTAndPostProcesses(): void;
  17682. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17683. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17684. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17685. protected _applyFilterValues(): void;
  17686. /**
  17687. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17688. * @param onCompiled Callback triggered at the and of the effects compilation
  17689. * @param options Sets of optional options forcing the compilation with different modes
  17690. */
  17691. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17692. useInstances: boolean;
  17693. }>): void;
  17694. /**
  17695. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17696. * @param options Sets of optional options forcing the compilation with different modes
  17697. * @returns A promise that resolves when the compilation completes
  17698. */
  17699. forceCompilationAsync(options?: Partial<{
  17700. useInstances: boolean;
  17701. }>): Promise<void>;
  17702. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17703. private _prepareShadowDefines;
  17704. /**
  17705. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17706. * @param subMesh The submesh we want to render in the shadow map
  17707. * @param useInstances Defines wether will draw in the map using instances
  17708. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17709. * @returns true if ready otherwise, false
  17710. */
  17711. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17712. /**
  17713. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17714. * @param defines Defines of the material we want to update
  17715. * @param lightIndex Index of the light in the enabled light list of the material
  17716. */
  17717. prepareDefines(defines: any, lightIndex: number): void;
  17718. /**
  17719. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17720. * defined in the generator but impacting the effect).
  17721. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17722. * @param effect The effect we are binfing the information for
  17723. */
  17724. bindShadowLight(lightIndex: string, effect: Effect): void;
  17725. /**
  17726. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17727. * (eq to shadow prjection matrix * light transform matrix)
  17728. * @returns The transform matrix used to create the shadow map
  17729. */
  17730. getTransformMatrix(): Matrix;
  17731. /**
  17732. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17733. * Cube and 2D textures for instance.
  17734. */
  17735. recreateShadowMap(): void;
  17736. protected _disposeBlurPostProcesses(): void;
  17737. protected _disposeRTTandPostProcesses(): void;
  17738. /**
  17739. * Disposes the ShadowGenerator.
  17740. * Returns nothing.
  17741. */
  17742. dispose(): void;
  17743. /**
  17744. * Serializes the shadow generator setup to a json object.
  17745. * @returns The serialized JSON object
  17746. */
  17747. serialize(): any;
  17748. /**
  17749. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17750. * @param parsedShadowGenerator The JSON object to parse
  17751. * @param scene The scene to create the shadow map for
  17752. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17753. * @returns The parsed shadow generator
  17754. */
  17755. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17756. }
  17757. }
  17758. declare module BABYLON {
  17759. /**
  17760. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17761. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17762. * 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.
  17763. */
  17764. export abstract class Light extends Node {
  17765. /**
  17766. * Falloff Default: light is falling off following the material specification:
  17767. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17768. */
  17769. static readonly FALLOFF_DEFAULT: number;
  17770. /**
  17771. * Falloff Physical: light is falling off following the inverse squared distance law.
  17772. */
  17773. static readonly FALLOFF_PHYSICAL: number;
  17774. /**
  17775. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17776. * to enhance interoperability with other engines.
  17777. */
  17778. static readonly FALLOFF_GLTF: number;
  17779. /**
  17780. * Falloff Standard: light is falling off like in the standard material
  17781. * to enhance interoperability with other materials.
  17782. */
  17783. static readonly FALLOFF_STANDARD: number;
  17784. /**
  17785. * If every light affecting the material is in this lightmapMode,
  17786. * material.lightmapTexture adds or multiplies
  17787. * (depends on material.useLightmapAsShadowmap)
  17788. * after every other light calculations.
  17789. */
  17790. static readonly LIGHTMAP_DEFAULT: number;
  17791. /**
  17792. * material.lightmapTexture as only diffuse lighting from this light
  17793. * adds only specular lighting from this light
  17794. * adds dynamic shadows
  17795. */
  17796. static readonly LIGHTMAP_SPECULAR: number;
  17797. /**
  17798. * material.lightmapTexture as only lighting
  17799. * no light calculation from this light
  17800. * only adds dynamic shadows from this light
  17801. */
  17802. static readonly LIGHTMAP_SHADOWSONLY: number;
  17803. /**
  17804. * Each light type uses the default quantity according to its type:
  17805. * point/spot lights use luminous intensity
  17806. * directional lights use illuminance
  17807. */
  17808. static readonly INTENSITYMODE_AUTOMATIC: number;
  17809. /**
  17810. * lumen (lm)
  17811. */
  17812. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17813. /**
  17814. * candela (lm/sr)
  17815. */
  17816. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17817. /**
  17818. * lux (lm/m^2)
  17819. */
  17820. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17821. /**
  17822. * nit (cd/m^2)
  17823. */
  17824. static readonly INTENSITYMODE_LUMINANCE: number;
  17825. /**
  17826. * Light type const id of the point light.
  17827. */
  17828. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17829. /**
  17830. * Light type const id of the directional light.
  17831. */
  17832. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17833. /**
  17834. * Light type const id of the spot light.
  17835. */
  17836. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17837. /**
  17838. * Light type const id of the hemispheric light.
  17839. */
  17840. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17841. /**
  17842. * Diffuse gives the basic color to an object.
  17843. */
  17844. diffuse: Color3;
  17845. /**
  17846. * Specular produces a highlight color on an object.
  17847. * Note: This is note affecting PBR materials.
  17848. */
  17849. specular: Color3;
  17850. /**
  17851. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17852. * falling off base on range or angle.
  17853. * This can be set to any values in Light.FALLOFF_x.
  17854. *
  17855. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17856. * other types of materials.
  17857. */
  17858. falloffType: number;
  17859. /**
  17860. * Strength of the light.
  17861. * Note: By default it is define in the framework own unit.
  17862. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17863. */
  17864. intensity: number;
  17865. private _range;
  17866. protected _inverseSquaredRange: number;
  17867. /**
  17868. * Defines how far from the source the light is impacting in scene units.
  17869. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17870. */
  17871. get range(): number;
  17872. /**
  17873. * Defines how far from the source the light is impacting in scene units.
  17874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17875. */
  17876. set range(value: number);
  17877. /**
  17878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17879. * of light.
  17880. */
  17881. private _photometricScale;
  17882. private _intensityMode;
  17883. /**
  17884. * Gets the photometric scale used to interpret the intensity.
  17885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17886. */
  17887. get intensityMode(): number;
  17888. /**
  17889. * Sets the photometric scale used to interpret the intensity.
  17890. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17891. */
  17892. set intensityMode(value: number);
  17893. private _radius;
  17894. /**
  17895. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17896. */
  17897. get radius(): number;
  17898. /**
  17899. * sets the light radius used by PBR Materials to simulate soft area lights.
  17900. */
  17901. set radius(value: number);
  17902. private _renderPriority;
  17903. /**
  17904. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17905. * exceeding the number allowed of the materials.
  17906. */
  17907. renderPriority: number;
  17908. private _shadowEnabled;
  17909. /**
  17910. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17911. * the current shadow generator.
  17912. */
  17913. get shadowEnabled(): boolean;
  17914. /**
  17915. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17916. * the current shadow generator.
  17917. */
  17918. set shadowEnabled(value: boolean);
  17919. private _includedOnlyMeshes;
  17920. /**
  17921. * Gets the only meshes impacted by this light.
  17922. */
  17923. get includedOnlyMeshes(): AbstractMesh[];
  17924. /**
  17925. * Sets the only meshes impacted by this light.
  17926. */
  17927. set includedOnlyMeshes(value: AbstractMesh[]);
  17928. private _excludedMeshes;
  17929. /**
  17930. * Gets the meshes not impacted by this light.
  17931. */
  17932. get excludedMeshes(): AbstractMesh[];
  17933. /**
  17934. * Sets the meshes not impacted by this light.
  17935. */
  17936. set excludedMeshes(value: AbstractMesh[]);
  17937. private _excludeWithLayerMask;
  17938. /**
  17939. * Gets the layer id use to find what meshes are not impacted by the light.
  17940. * Inactive if 0
  17941. */
  17942. get excludeWithLayerMask(): number;
  17943. /**
  17944. * Sets the layer id use to find what meshes are not impacted by the light.
  17945. * Inactive if 0
  17946. */
  17947. set excludeWithLayerMask(value: number);
  17948. private _includeOnlyWithLayerMask;
  17949. /**
  17950. * Gets the layer id use to find what meshes are impacted by the light.
  17951. * Inactive if 0
  17952. */
  17953. get includeOnlyWithLayerMask(): number;
  17954. /**
  17955. * Sets the layer id use to find what meshes are impacted by the light.
  17956. * Inactive if 0
  17957. */
  17958. set includeOnlyWithLayerMask(value: number);
  17959. private _lightmapMode;
  17960. /**
  17961. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17962. */
  17963. get lightmapMode(): number;
  17964. /**
  17965. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17966. */
  17967. set lightmapMode(value: number);
  17968. /**
  17969. * Shadow generator associted to the light.
  17970. * @hidden Internal use only.
  17971. */
  17972. _shadowGenerator: Nullable<IShadowGenerator>;
  17973. /**
  17974. * @hidden Internal use only.
  17975. */
  17976. _excludedMeshesIds: string[];
  17977. /**
  17978. * @hidden Internal use only.
  17979. */
  17980. _includedOnlyMeshesIds: string[];
  17981. /**
  17982. * The current light unifom buffer.
  17983. * @hidden Internal use only.
  17984. */
  17985. _uniformBuffer: UniformBuffer;
  17986. /** @hidden */
  17987. _renderId: number;
  17988. /**
  17989. * Creates a Light object in the scene.
  17990. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17991. * @param name The firendly name of the light
  17992. * @param scene The scene the light belongs too
  17993. */
  17994. constructor(name: string, scene: Scene);
  17995. protected abstract _buildUniformLayout(): void;
  17996. /**
  17997. * Sets the passed Effect "effect" with the Light information.
  17998. * @param effect The effect to update
  17999. * @param lightIndex The index of the light in the effect to update
  18000. * @returns The light
  18001. */
  18002. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18003. /**
  18004. * Sets the passed Effect "effect" with the Light textures.
  18005. * @param effect The effect to update
  18006. * @param lightIndex The index of the light in the effect to update
  18007. * @returns The light
  18008. */
  18009. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18010. /**
  18011. * Binds the lights information from the scene to the effect for the given mesh.
  18012. * @param lightIndex Light index
  18013. * @param scene The scene where the light belongs to
  18014. * @param effect The effect we are binding the data to
  18015. * @param useSpecular Defines if specular is supported
  18016. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18017. */
  18018. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18019. /**
  18020. * Sets the passed Effect "effect" with the Light information.
  18021. * @param effect The effect to update
  18022. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18023. * @returns The light
  18024. */
  18025. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18026. /**
  18027. * Returns the string "Light".
  18028. * @returns the class name
  18029. */
  18030. getClassName(): string;
  18031. /** @hidden */
  18032. readonly _isLight: boolean;
  18033. /**
  18034. * Converts the light information to a readable string for debug purpose.
  18035. * @param fullDetails Supports for multiple levels of logging within scene loading
  18036. * @returns the human readable light info
  18037. */
  18038. toString(fullDetails?: boolean): string;
  18039. /** @hidden */
  18040. protected _syncParentEnabledState(): void;
  18041. /**
  18042. * Set the enabled state of this node.
  18043. * @param value - the new enabled state
  18044. */
  18045. setEnabled(value: boolean): void;
  18046. /**
  18047. * Returns the Light associated shadow generator if any.
  18048. * @return the associated shadow generator.
  18049. */
  18050. getShadowGenerator(): Nullable<IShadowGenerator>;
  18051. /**
  18052. * Returns a Vector3, the absolute light position in the World.
  18053. * @returns the world space position of the light
  18054. */
  18055. getAbsolutePosition(): Vector3;
  18056. /**
  18057. * Specifies if the light will affect the passed mesh.
  18058. * @param mesh The mesh to test against the light
  18059. * @return true the mesh is affected otherwise, false.
  18060. */
  18061. canAffectMesh(mesh: AbstractMesh): boolean;
  18062. /**
  18063. * Sort function to order lights for rendering.
  18064. * @param a First Light object to compare to second.
  18065. * @param b Second Light object to compare first.
  18066. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18067. */
  18068. static CompareLightsPriority(a: Light, b: Light): number;
  18069. /**
  18070. * Releases resources associated with this node.
  18071. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18072. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18073. */
  18074. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18075. /**
  18076. * Returns the light type ID (integer).
  18077. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18078. */
  18079. getTypeID(): number;
  18080. /**
  18081. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18082. * @returns the scaled intensity in intensity mode unit
  18083. */
  18084. getScaledIntensity(): number;
  18085. /**
  18086. * Returns a new Light object, named "name", from the current one.
  18087. * @param name The name of the cloned light
  18088. * @param newParent The parent of this light, if it has one
  18089. * @returns the new created light
  18090. */
  18091. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18092. /**
  18093. * Serializes the current light into a Serialization object.
  18094. * @returns the serialized object.
  18095. */
  18096. serialize(): any;
  18097. /**
  18098. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18099. * This new light is named "name" and added to the passed scene.
  18100. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18101. * @param name The friendly name of the light
  18102. * @param scene The scene the new light will belong to
  18103. * @returns the constructor function
  18104. */
  18105. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18106. /**
  18107. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18108. * @param parsedLight The JSON representation of the light
  18109. * @param scene The scene to create the parsed light in
  18110. * @returns the created light after parsing
  18111. */
  18112. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18113. private _hookArrayForExcluded;
  18114. private _hookArrayForIncludedOnly;
  18115. private _resyncMeshes;
  18116. /**
  18117. * Forces the meshes to update their light related information in their rendering used effects
  18118. * @hidden Internal Use Only
  18119. */
  18120. _markMeshesAsLightDirty(): void;
  18121. /**
  18122. * Recomputes the cached photometric scale if needed.
  18123. */
  18124. private _computePhotometricScale;
  18125. /**
  18126. * Returns the Photometric Scale according to the light type and intensity mode.
  18127. */
  18128. private _getPhotometricScale;
  18129. /**
  18130. * Reorder the light in the scene according to their defined priority.
  18131. * @hidden Internal Use Only
  18132. */
  18133. _reorderLightsInScene(): void;
  18134. /**
  18135. * Prepares the list of defines specific to the light type.
  18136. * @param defines the list of defines
  18137. * @param lightIndex defines the index of the light for the effect
  18138. */
  18139. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18140. }
  18141. }
  18142. declare module BABYLON {
  18143. /**
  18144. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18145. * This is the base of the follow, arc rotate cameras and Free camera
  18146. * @see http://doc.babylonjs.com/features/cameras
  18147. */
  18148. export class TargetCamera extends Camera {
  18149. private static _RigCamTransformMatrix;
  18150. private static _TargetTransformMatrix;
  18151. private static _TargetFocalPoint;
  18152. /**
  18153. * Define the current direction the camera is moving to
  18154. */
  18155. cameraDirection: Vector3;
  18156. /**
  18157. * Define the current rotation the camera is rotating to
  18158. */
  18159. cameraRotation: Vector2;
  18160. /**
  18161. * When set, the up vector of the camera will be updated by the rotation of the camera
  18162. */
  18163. updateUpVectorFromRotation: boolean;
  18164. private _tmpQuaternion;
  18165. /**
  18166. * Define the current rotation of the camera
  18167. */
  18168. rotation: Vector3;
  18169. /**
  18170. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18171. */
  18172. rotationQuaternion: Quaternion;
  18173. /**
  18174. * Define the current speed of the camera
  18175. */
  18176. speed: number;
  18177. /**
  18178. * Add constraint to the camera to prevent it to move freely in all directions and
  18179. * around all axis.
  18180. */
  18181. noRotationConstraint: boolean;
  18182. /**
  18183. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18184. * panning
  18185. */
  18186. invertRotation: boolean;
  18187. /**
  18188. * Speed multiplier for inverse camera panning
  18189. */
  18190. inverseRotationSpeed: number;
  18191. /**
  18192. * Define the current target of the camera as an object or a position.
  18193. */
  18194. lockedTarget: any;
  18195. /** @hidden */
  18196. _currentTarget: Vector3;
  18197. /** @hidden */
  18198. _initialFocalDistance: number;
  18199. /** @hidden */
  18200. _viewMatrix: Matrix;
  18201. /** @hidden */
  18202. _camMatrix: Matrix;
  18203. /** @hidden */
  18204. _cameraTransformMatrix: Matrix;
  18205. /** @hidden */
  18206. _cameraRotationMatrix: Matrix;
  18207. /** @hidden */
  18208. _referencePoint: Vector3;
  18209. /** @hidden */
  18210. _transformedReferencePoint: Vector3;
  18211. protected _globalCurrentTarget: Vector3;
  18212. protected _globalCurrentUpVector: Vector3;
  18213. /** @hidden */
  18214. _reset: () => void;
  18215. private _defaultUp;
  18216. /**
  18217. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18218. * This is the base of the follow, arc rotate cameras and Free camera
  18219. * @see http://doc.babylonjs.com/features/cameras
  18220. * @param name Defines the name of the camera in the scene
  18221. * @param position Defines the start position of the camera in the scene
  18222. * @param scene Defines the scene the camera belongs to
  18223. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18224. */
  18225. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18226. /**
  18227. * Gets the position in front of the camera at a given distance.
  18228. * @param distance The distance from the camera we want the position to be
  18229. * @returns the position
  18230. */
  18231. getFrontPosition(distance: number): Vector3;
  18232. /** @hidden */
  18233. _getLockedTargetPosition(): Nullable<Vector3>;
  18234. private _storedPosition;
  18235. private _storedRotation;
  18236. private _storedRotationQuaternion;
  18237. /**
  18238. * Store current camera state of the camera (fov, position, rotation, etc..)
  18239. * @returns the camera
  18240. */
  18241. storeState(): Camera;
  18242. /**
  18243. * Restored camera state. You must call storeState() first
  18244. * @returns whether it was successful or not
  18245. * @hidden
  18246. */
  18247. _restoreStateValues(): boolean;
  18248. /** @hidden */
  18249. _initCache(): void;
  18250. /** @hidden */
  18251. _updateCache(ignoreParentClass?: boolean): void;
  18252. /** @hidden */
  18253. _isSynchronizedViewMatrix(): boolean;
  18254. /** @hidden */
  18255. _computeLocalCameraSpeed(): number;
  18256. /**
  18257. * Defines the target the camera should look at.
  18258. * @param target Defines the new target as a Vector or a mesh
  18259. */
  18260. setTarget(target: Vector3): void;
  18261. /**
  18262. * Return the current target position of the camera. This value is expressed in local space.
  18263. * @returns the target position
  18264. */
  18265. getTarget(): Vector3;
  18266. /** @hidden */
  18267. _decideIfNeedsToMove(): boolean;
  18268. /** @hidden */
  18269. _updatePosition(): void;
  18270. /** @hidden */
  18271. _checkInputs(): void;
  18272. protected _updateCameraRotationMatrix(): void;
  18273. /**
  18274. * 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)
  18275. * @returns the current camera
  18276. */
  18277. private _rotateUpVectorWithCameraRotationMatrix;
  18278. private _cachedRotationZ;
  18279. private _cachedQuaternionRotationZ;
  18280. /** @hidden */
  18281. _getViewMatrix(): Matrix;
  18282. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18283. /**
  18284. * @hidden
  18285. */
  18286. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18287. /**
  18288. * @hidden
  18289. */
  18290. _updateRigCameras(): void;
  18291. private _getRigCamPositionAndTarget;
  18292. /**
  18293. * Gets the current object class name.
  18294. * @return the class name
  18295. */
  18296. getClassName(): string;
  18297. }
  18298. }
  18299. declare module BABYLON {
  18300. /**
  18301. * Gather the list of keyboard event types as constants.
  18302. */
  18303. export class KeyboardEventTypes {
  18304. /**
  18305. * The keydown event is fired when a key becomes active (pressed).
  18306. */
  18307. static readonly KEYDOWN: number;
  18308. /**
  18309. * The keyup event is fired when a key has been released.
  18310. */
  18311. static readonly KEYUP: number;
  18312. }
  18313. /**
  18314. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18315. */
  18316. export class KeyboardInfo {
  18317. /**
  18318. * Defines the type of event (KeyboardEventTypes)
  18319. */
  18320. type: number;
  18321. /**
  18322. * Defines the related dom event
  18323. */
  18324. event: KeyboardEvent;
  18325. /**
  18326. * Instantiates a new keyboard info.
  18327. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18328. * @param type Defines the type of event (KeyboardEventTypes)
  18329. * @param event Defines the related dom event
  18330. */
  18331. constructor(
  18332. /**
  18333. * Defines the type of event (KeyboardEventTypes)
  18334. */
  18335. type: number,
  18336. /**
  18337. * Defines the related dom event
  18338. */
  18339. event: KeyboardEvent);
  18340. }
  18341. /**
  18342. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18343. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18344. */
  18345. export class KeyboardInfoPre extends KeyboardInfo {
  18346. /**
  18347. * Defines the type of event (KeyboardEventTypes)
  18348. */
  18349. type: number;
  18350. /**
  18351. * Defines the related dom event
  18352. */
  18353. event: KeyboardEvent;
  18354. /**
  18355. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18356. */
  18357. skipOnPointerObservable: boolean;
  18358. /**
  18359. * Instantiates a new keyboard pre info.
  18360. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18361. * @param type Defines the type of event (KeyboardEventTypes)
  18362. * @param event Defines the related dom event
  18363. */
  18364. constructor(
  18365. /**
  18366. * Defines the type of event (KeyboardEventTypes)
  18367. */
  18368. type: number,
  18369. /**
  18370. * Defines the related dom event
  18371. */
  18372. event: KeyboardEvent);
  18373. }
  18374. }
  18375. declare module BABYLON {
  18376. /**
  18377. * Manage the keyboard inputs to control the movement of a free camera.
  18378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18379. */
  18380. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18381. /**
  18382. * Defines the camera the input is attached to.
  18383. */
  18384. camera: FreeCamera;
  18385. /**
  18386. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18387. */
  18388. keysUp: number[];
  18389. /**
  18390. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18391. */
  18392. keysUpward: number[];
  18393. /**
  18394. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18395. */
  18396. keysDown: number[];
  18397. /**
  18398. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18399. */
  18400. keysDownward: number[];
  18401. /**
  18402. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18403. */
  18404. keysLeft: number[];
  18405. /**
  18406. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18407. */
  18408. keysRight: number[];
  18409. private _keys;
  18410. private _onCanvasBlurObserver;
  18411. private _onKeyboardObserver;
  18412. private _engine;
  18413. private _scene;
  18414. /**
  18415. * Attach the input controls to a specific dom element to get the input from.
  18416. * @param element Defines the element the controls should be listened from
  18417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18418. */
  18419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18420. /**
  18421. * Detach the current controls from the specified dom element.
  18422. * @param element Defines the element to stop listening the inputs from
  18423. */
  18424. detachControl(element: Nullable<HTMLElement>): void;
  18425. /**
  18426. * Update the current camera state depending on the inputs that have been used this frame.
  18427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18428. */
  18429. checkInputs(): void;
  18430. /**
  18431. * Gets the class name of the current intput.
  18432. * @returns the class name
  18433. */
  18434. getClassName(): string;
  18435. /** @hidden */
  18436. _onLostFocus(): void;
  18437. /**
  18438. * Get the friendly name associated with the input class.
  18439. * @returns the input friendly name
  18440. */
  18441. getSimpleName(): string;
  18442. }
  18443. }
  18444. declare module BABYLON {
  18445. /**
  18446. * Gather the list of pointer event types as constants.
  18447. */
  18448. export class PointerEventTypes {
  18449. /**
  18450. * 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.
  18451. */
  18452. static readonly POINTERDOWN: number;
  18453. /**
  18454. * The pointerup event is fired when a pointer is no longer active.
  18455. */
  18456. static readonly POINTERUP: number;
  18457. /**
  18458. * The pointermove event is fired when a pointer changes coordinates.
  18459. */
  18460. static readonly POINTERMOVE: number;
  18461. /**
  18462. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18463. */
  18464. static readonly POINTERWHEEL: number;
  18465. /**
  18466. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18467. */
  18468. static readonly POINTERPICK: number;
  18469. /**
  18470. * The pointertap event is fired when a the object has been touched and released without drag.
  18471. */
  18472. static readonly POINTERTAP: number;
  18473. /**
  18474. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18475. */
  18476. static readonly POINTERDOUBLETAP: number;
  18477. }
  18478. /**
  18479. * Base class of pointer info types.
  18480. */
  18481. export class PointerInfoBase {
  18482. /**
  18483. * Defines the type of event (PointerEventTypes)
  18484. */
  18485. type: number;
  18486. /**
  18487. * Defines the related dom event
  18488. */
  18489. event: PointerEvent | MouseWheelEvent;
  18490. /**
  18491. * Instantiates the base class of pointers info.
  18492. * @param type Defines the type of event (PointerEventTypes)
  18493. * @param event Defines the related dom event
  18494. */
  18495. constructor(
  18496. /**
  18497. * Defines the type of event (PointerEventTypes)
  18498. */
  18499. type: number,
  18500. /**
  18501. * Defines the related dom event
  18502. */
  18503. event: PointerEvent | MouseWheelEvent);
  18504. }
  18505. /**
  18506. * This class is used to store pointer related info for the onPrePointerObservable event.
  18507. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18508. */
  18509. export class PointerInfoPre extends PointerInfoBase {
  18510. /**
  18511. * Ray from a pointer if availible (eg. 6dof controller)
  18512. */
  18513. ray: Nullable<Ray>;
  18514. /**
  18515. * Defines the local position of the pointer on the canvas.
  18516. */
  18517. localPosition: Vector2;
  18518. /**
  18519. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18520. */
  18521. skipOnPointerObservable: boolean;
  18522. /**
  18523. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18524. * @param type Defines the type of event (PointerEventTypes)
  18525. * @param event Defines the related dom event
  18526. * @param localX Defines the local x coordinates of the pointer when the event occured
  18527. * @param localY Defines the local y coordinates of the pointer when the event occured
  18528. */
  18529. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18530. }
  18531. /**
  18532. * This type contains all the data related to a pointer event in Babylon.js.
  18533. * 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.
  18534. */
  18535. export class PointerInfo extends PointerInfoBase {
  18536. /**
  18537. * Defines the picking info associated to the info (if any)\
  18538. */
  18539. pickInfo: Nullable<PickingInfo>;
  18540. /**
  18541. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18542. * @param type Defines the type of event (PointerEventTypes)
  18543. * @param event Defines the related dom event
  18544. * @param pickInfo Defines the picking info associated to the info (if any)\
  18545. */
  18546. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18547. /**
  18548. * Defines the picking info associated to the info (if any)\
  18549. */
  18550. pickInfo: Nullable<PickingInfo>);
  18551. }
  18552. /**
  18553. * Data relating to a touch event on the screen.
  18554. */
  18555. export interface PointerTouch {
  18556. /**
  18557. * X coordinate of touch.
  18558. */
  18559. x: number;
  18560. /**
  18561. * Y coordinate of touch.
  18562. */
  18563. y: number;
  18564. /**
  18565. * Id of touch. Unique for each finger.
  18566. */
  18567. pointerId: number;
  18568. /**
  18569. * Event type passed from DOM.
  18570. */
  18571. type: any;
  18572. }
  18573. }
  18574. declare module BABYLON {
  18575. /**
  18576. * Manage the mouse inputs to control the movement of a free camera.
  18577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18578. */
  18579. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18580. /**
  18581. * Define if touch is enabled in the mouse input
  18582. */
  18583. touchEnabled: boolean;
  18584. /**
  18585. * Defines the camera the input is attached to.
  18586. */
  18587. camera: FreeCamera;
  18588. /**
  18589. * Defines the buttons associated with the input to handle camera move.
  18590. */
  18591. buttons: number[];
  18592. /**
  18593. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18594. */
  18595. angularSensibility: number;
  18596. private _pointerInput;
  18597. private _onMouseMove;
  18598. private _observer;
  18599. private previousPosition;
  18600. /**
  18601. * Observable for when a pointer move event occurs containing the move offset
  18602. */
  18603. onPointerMovedObservable: Observable<{
  18604. offsetX: number;
  18605. offsetY: number;
  18606. }>;
  18607. /**
  18608. * @hidden
  18609. * If the camera should be rotated automatically based on pointer movement
  18610. */
  18611. _allowCameraRotation: boolean;
  18612. /**
  18613. * Manage the mouse inputs to control the movement of a free camera.
  18614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18615. * @param touchEnabled Defines if touch is enabled or not
  18616. */
  18617. constructor(
  18618. /**
  18619. * Define if touch is enabled in the mouse input
  18620. */
  18621. touchEnabled?: boolean);
  18622. /**
  18623. * Attach the input controls to a specific dom element to get the input from.
  18624. * @param element Defines the element the controls should be listened from
  18625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18626. */
  18627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18628. /**
  18629. * Called on JS contextmenu event.
  18630. * Override this method to provide functionality.
  18631. */
  18632. protected onContextMenu(evt: PointerEvent): void;
  18633. /**
  18634. * Detach the current controls from the specified dom element.
  18635. * @param element Defines the element to stop listening the inputs from
  18636. */
  18637. detachControl(element: Nullable<HTMLElement>): void;
  18638. /**
  18639. * Gets the class name of the current intput.
  18640. * @returns the class name
  18641. */
  18642. getClassName(): string;
  18643. /**
  18644. * Get the friendly name associated with the input class.
  18645. * @returns the input friendly name
  18646. */
  18647. getSimpleName(): string;
  18648. }
  18649. }
  18650. declare module BABYLON {
  18651. /**
  18652. * Manage the touch inputs to control the movement of a free camera.
  18653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18654. */
  18655. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18656. /**
  18657. * Defines the camera the input is attached to.
  18658. */
  18659. camera: FreeCamera;
  18660. /**
  18661. * Defines the touch sensibility for rotation.
  18662. * The higher the faster.
  18663. */
  18664. touchAngularSensibility: number;
  18665. /**
  18666. * Defines the touch sensibility for move.
  18667. * The higher the faster.
  18668. */
  18669. touchMoveSensibility: number;
  18670. private _offsetX;
  18671. private _offsetY;
  18672. private _pointerPressed;
  18673. private _pointerInput;
  18674. private _observer;
  18675. private _onLostFocus;
  18676. /**
  18677. * Attach the input controls to a specific dom element to get the input from.
  18678. * @param element Defines the element the controls should be listened from
  18679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18680. */
  18681. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18682. /**
  18683. * Detach the current controls from the specified dom element.
  18684. * @param element Defines the element to stop listening the inputs from
  18685. */
  18686. detachControl(element: Nullable<HTMLElement>): void;
  18687. /**
  18688. * Update the current camera state depending on the inputs that have been used this frame.
  18689. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18690. */
  18691. checkInputs(): void;
  18692. /**
  18693. * Gets the class name of the current intput.
  18694. * @returns the class name
  18695. */
  18696. getClassName(): string;
  18697. /**
  18698. * Get the friendly name associated with the input class.
  18699. * @returns the input friendly name
  18700. */
  18701. getSimpleName(): string;
  18702. }
  18703. }
  18704. declare module BABYLON {
  18705. /**
  18706. * Default Inputs manager for the FreeCamera.
  18707. * It groups all the default supported inputs for ease of use.
  18708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18709. */
  18710. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18711. /**
  18712. * @hidden
  18713. */
  18714. _mouseInput: Nullable<FreeCameraMouseInput>;
  18715. /**
  18716. * Instantiates a new FreeCameraInputsManager.
  18717. * @param camera Defines the camera the inputs belong to
  18718. */
  18719. constructor(camera: FreeCamera);
  18720. /**
  18721. * Add keyboard input support to the input manager.
  18722. * @returns the current input manager
  18723. */
  18724. addKeyboard(): FreeCameraInputsManager;
  18725. /**
  18726. * Add mouse input support to the input manager.
  18727. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18728. * @returns the current input manager
  18729. */
  18730. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18731. /**
  18732. * Removes the mouse input support from the manager
  18733. * @returns the current input manager
  18734. */
  18735. removeMouse(): FreeCameraInputsManager;
  18736. /**
  18737. * Add touch input support to the input manager.
  18738. * @returns the current input manager
  18739. */
  18740. addTouch(): FreeCameraInputsManager;
  18741. /**
  18742. * Remove all attached input methods from a camera
  18743. */
  18744. clear(): void;
  18745. }
  18746. }
  18747. declare module BABYLON {
  18748. /**
  18749. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18750. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18751. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18752. */
  18753. export class FreeCamera extends TargetCamera {
  18754. /**
  18755. * Define the collision ellipsoid of the camera.
  18756. * This is helpful to simulate a camera body like the player body around the camera
  18757. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18758. */
  18759. ellipsoid: Vector3;
  18760. /**
  18761. * Define an offset for the position of the ellipsoid around the camera.
  18762. * This can be helpful to determine the center of the body near the gravity center of the body
  18763. * instead of its head.
  18764. */
  18765. ellipsoidOffset: Vector3;
  18766. /**
  18767. * Enable or disable collisions of the camera with the rest of the scene objects.
  18768. */
  18769. checkCollisions: boolean;
  18770. /**
  18771. * Enable or disable gravity on the camera.
  18772. */
  18773. applyGravity: boolean;
  18774. /**
  18775. * Define the input manager associated to the camera.
  18776. */
  18777. inputs: FreeCameraInputsManager;
  18778. /**
  18779. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18780. * Higher values reduce sensitivity.
  18781. */
  18782. get angularSensibility(): number;
  18783. /**
  18784. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18785. * Higher values reduce sensitivity.
  18786. */
  18787. set angularSensibility(value: number);
  18788. /**
  18789. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18790. */
  18791. get keysUp(): number[];
  18792. set keysUp(value: number[]);
  18793. /**
  18794. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18795. */
  18796. get keysUpward(): number[];
  18797. set keysUpward(value: number[]);
  18798. /**
  18799. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18800. */
  18801. get keysDown(): number[];
  18802. set keysDown(value: number[]);
  18803. /**
  18804. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18805. */
  18806. get keysDownward(): number[];
  18807. set keysDownward(value: number[]);
  18808. /**
  18809. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18810. */
  18811. get keysLeft(): number[];
  18812. set keysLeft(value: number[]);
  18813. /**
  18814. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18815. */
  18816. get keysRight(): number[];
  18817. set keysRight(value: number[]);
  18818. /**
  18819. * Event raised when the camera collide with a mesh in the scene.
  18820. */
  18821. onCollide: (collidedMesh: AbstractMesh) => void;
  18822. private _collider;
  18823. private _needMoveForGravity;
  18824. private _oldPosition;
  18825. private _diffPosition;
  18826. private _newPosition;
  18827. /** @hidden */
  18828. _localDirection: Vector3;
  18829. /** @hidden */
  18830. _transformedDirection: Vector3;
  18831. /**
  18832. * Instantiates a Free Camera.
  18833. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18834. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18835. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18836. * @param name Define the name of the camera in the scene
  18837. * @param position Define the start position of the camera in the scene
  18838. * @param scene Define the scene the camera belongs to
  18839. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18840. */
  18841. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18842. /**
  18843. * Attached controls to the current camera.
  18844. * @param element Defines the element the controls should be listened from
  18845. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18846. */
  18847. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18848. /**
  18849. * Detach the current controls from the camera.
  18850. * The camera will stop reacting to inputs.
  18851. * @param element Defines the element to stop listening the inputs from
  18852. */
  18853. detachControl(element: HTMLElement): void;
  18854. private _collisionMask;
  18855. /**
  18856. * Define a collision mask to limit the list of object the camera can collide with
  18857. */
  18858. get collisionMask(): number;
  18859. set collisionMask(mask: number);
  18860. /** @hidden */
  18861. _collideWithWorld(displacement: Vector3): void;
  18862. private _onCollisionPositionChange;
  18863. /** @hidden */
  18864. _checkInputs(): void;
  18865. /** @hidden */
  18866. _decideIfNeedsToMove(): boolean;
  18867. /** @hidden */
  18868. _updatePosition(): void;
  18869. /**
  18870. * Destroy the camera and release the current resources hold by it.
  18871. */
  18872. dispose(): void;
  18873. /**
  18874. * Gets the current object class name.
  18875. * @return the class name
  18876. */
  18877. getClassName(): string;
  18878. }
  18879. }
  18880. declare module BABYLON {
  18881. /**
  18882. * Represents a gamepad control stick position
  18883. */
  18884. export class StickValues {
  18885. /**
  18886. * The x component of the control stick
  18887. */
  18888. x: number;
  18889. /**
  18890. * The y component of the control stick
  18891. */
  18892. y: number;
  18893. /**
  18894. * Initializes the gamepad x and y control stick values
  18895. * @param x The x component of the gamepad control stick value
  18896. * @param y The y component of the gamepad control stick value
  18897. */
  18898. constructor(
  18899. /**
  18900. * The x component of the control stick
  18901. */
  18902. x: number,
  18903. /**
  18904. * The y component of the control stick
  18905. */
  18906. y: number);
  18907. }
  18908. /**
  18909. * An interface which manages callbacks for gamepad button changes
  18910. */
  18911. export interface GamepadButtonChanges {
  18912. /**
  18913. * Called when a gamepad has been changed
  18914. */
  18915. changed: boolean;
  18916. /**
  18917. * Called when a gamepad press event has been triggered
  18918. */
  18919. pressChanged: boolean;
  18920. /**
  18921. * Called when a touch event has been triggered
  18922. */
  18923. touchChanged: boolean;
  18924. /**
  18925. * Called when a value has changed
  18926. */
  18927. valueChanged: boolean;
  18928. }
  18929. /**
  18930. * Represents a gamepad
  18931. */
  18932. export class Gamepad {
  18933. /**
  18934. * The id of the gamepad
  18935. */
  18936. id: string;
  18937. /**
  18938. * The index of the gamepad
  18939. */
  18940. index: number;
  18941. /**
  18942. * The browser gamepad
  18943. */
  18944. browserGamepad: any;
  18945. /**
  18946. * Specifies what type of gamepad this represents
  18947. */
  18948. type: number;
  18949. private _leftStick;
  18950. private _rightStick;
  18951. /** @hidden */
  18952. _isConnected: boolean;
  18953. private _leftStickAxisX;
  18954. private _leftStickAxisY;
  18955. private _rightStickAxisX;
  18956. private _rightStickAxisY;
  18957. /**
  18958. * Triggered when the left control stick has been changed
  18959. */
  18960. private _onleftstickchanged;
  18961. /**
  18962. * Triggered when the right control stick has been changed
  18963. */
  18964. private _onrightstickchanged;
  18965. /**
  18966. * Represents a gamepad controller
  18967. */
  18968. static GAMEPAD: number;
  18969. /**
  18970. * Represents a generic controller
  18971. */
  18972. static GENERIC: number;
  18973. /**
  18974. * Represents an XBox controller
  18975. */
  18976. static XBOX: number;
  18977. /**
  18978. * Represents a pose-enabled controller
  18979. */
  18980. static POSE_ENABLED: number;
  18981. /**
  18982. * Represents an Dual Shock controller
  18983. */
  18984. static DUALSHOCK: number;
  18985. /**
  18986. * Specifies whether the left control stick should be Y-inverted
  18987. */
  18988. protected _invertLeftStickY: boolean;
  18989. /**
  18990. * Specifies if the gamepad has been connected
  18991. */
  18992. get isConnected(): boolean;
  18993. /**
  18994. * Initializes the gamepad
  18995. * @param id The id of the gamepad
  18996. * @param index The index of the gamepad
  18997. * @param browserGamepad The browser gamepad
  18998. * @param leftStickX The x component of the left joystick
  18999. * @param leftStickY The y component of the left joystick
  19000. * @param rightStickX The x component of the right joystick
  19001. * @param rightStickY The y component of the right joystick
  19002. */
  19003. constructor(
  19004. /**
  19005. * The id of the gamepad
  19006. */
  19007. id: string,
  19008. /**
  19009. * The index of the gamepad
  19010. */
  19011. index: number,
  19012. /**
  19013. * The browser gamepad
  19014. */
  19015. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19016. /**
  19017. * Callback triggered when the left joystick has changed
  19018. * @param callback
  19019. */
  19020. onleftstickchanged(callback: (values: StickValues) => void): void;
  19021. /**
  19022. * Callback triggered when the right joystick has changed
  19023. * @param callback
  19024. */
  19025. onrightstickchanged(callback: (values: StickValues) => void): void;
  19026. /**
  19027. * Gets the left joystick
  19028. */
  19029. get leftStick(): StickValues;
  19030. /**
  19031. * Sets the left joystick values
  19032. */
  19033. set leftStick(newValues: StickValues);
  19034. /**
  19035. * Gets the right joystick
  19036. */
  19037. get rightStick(): StickValues;
  19038. /**
  19039. * Sets the right joystick value
  19040. */
  19041. set rightStick(newValues: StickValues);
  19042. /**
  19043. * Updates the gamepad joystick positions
  19044. */
  19045. update(): void;
  19046. /**
  19047. * Disposes the gamepad
  19048. */
  19049. dispose(): void;
  19050. }
  19051. /**
  19052. * Represents a generic gamepad
  19053. */
  19054. export class GenericPad extends Gamepad {
  19055. private _buttons;
  19056. private _onbuttondown;
  19057. private _onbuttonup;
  19058. /**
  19059. * Observable triggered when a button has been pressed
  19060. */
  19061. onButtonDownObservable: Observable<number>;
  19062. /**
  19063. * Observable triggered when a button has been released
  19064. */
  19065. onButtonUpObservable: Observable<number>;
  19066. /**
  19067. * Callback triggered when a button has been pressed
  19068. * @param callback Called when a button has been pressed
  19069. */
  19070. onbuttondown(callback: (buttonPressed: number) => void): void;
  19071. /**
  19072. * Callback triggered when a button has been released
  19073. * @param callback Called when a button has been released
  19074. */
  19075. onbuttonup(callback: (buttonReleased: number) => void): void;
  19076. /**
  19077. * Initializes the generic gamepad
  19078. * @param id The id of the generic gamepad
  19079. * @param index The index of the generic gamepad
  19080. * @param browserGamepad The browser gamepad
  19081. */
  19082. constructor(id: string, index: number, browserGamepad: any);
  19083. private _setButtonValue;
  19084. /**
  19085. * Updates the generic gamepad
  19086. */
  19087. update(): void;
  19088. /**
  19089. * Disposes the generic gamepad
  19090. */
  19091. dispose(): void;
  19092. }
  19093. }
  19094. declare module BABYLON {
  19095. /**
  19096. * Defines the types of pose enabled controllers that are supported
  19097. */
  19098. export enum PoseEnabledControllerType {
  19099. /**
  19100. * HTC Vive
  19101. */
  19102. VIVE = 0,
  19103. /**
  19104. * Oculus Rift
  19105. */
  19106. OCULUS = 1,
  19107. /**
  19108. * Windows mixed reality
  19109. */
  19110. WINDOWS = 2,
  19111. /**
  19112. * Samsung gear VR
  19113. */
  19114. GEAR_VR = 3,
  19115. /**
  19116. * Google Daydream
  19117. */
  19118. DAYDREAM = 4,
  19119. /**
  19120. * Generic
  19121. */
  19122. GENERIC = 5
  19123. }
  19124. /**
  19125. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19126. */
  19127. export interface MutableGamepadButton {
  19128. /**
  19129. * Value of the button/trigger
  19130. */
  19131. value: number;
  19132. /**
  19133. * If the button/trigger is currently touched
  19134. */
  19135. touched: boolean;
  19136. /**
  19137. * If the button/trigger is currently pressed
  19138. */
  19139. pressed: boolean;
  19140. }
  19141. /**
  19142. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19143. * @hidden
  19144. */
  19145. export interface ExtendedGamepadButton extends GamepadButton {
  19146. /**
  19147. * If the button/trigger is currently pressed
  19148. */
  19149. readonly pressed: boolean;
  19150. /**
  19151. * If the button/trigger is currently touched
  19152. */
  19153. readonly touched: boolean;
  19154. /**
  19155. * Value of the button/trigger
  19156. */
  19157. readonly value: number;
  19158. }
  19159. /** @hidden */
  19160. export interface _GamePadFactory {
  19161. /**
  19162. * Returns whether or not the current gamepad can be created for this type of controller.
  19163. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19164. * @returns true if it can be created, otherwise false
  19165. */
  19166. canCreate(gamepadInfo: any): boolean;
  19167. /**
  19168. * Creates a new instance of the Gamepad.
  19169. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19170. * @returns the new gamepad instance
  19171. */
  19172. create(gamepadInfo: any): Gamepad;
  19173. }
  19174. /**
  19175. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19176. */
  19177. export class PoseEnabledControllerHelper {
  19178. /** @hidden */
  19179. static _ControllerFactories: _GamePadFactory[];
  19180. /** @hidden */
  19181. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19182. /**
  19183. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19184. * @param vrGamepad the gamepad to initialized
  19185. * @returns a vr controller of the type the gamepad identified as
  19186. */
  19187. static InitiateController(vrGamepad: any): Gamepad;
  19188. }
  19189. /**
  19190. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19191. */
  19192. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19193. /**
  19194. * If the controller is used in a webXR session
  19195. */
  19196. isXR: boolean;
  19197. private _deviceRoomPosition;
  19198. private _deviceRoomRotationQuaternion;
  19199. /**
  19200. * The device position in babylon space
  19201. */
  19202. devicePosition: Vector3;
  19203. /**
  19204. * The device rotation in babylon space
  19205. */
  19206. deviceRotationQuaternion: Quaternion;
  19207. /**
  19208. * The scale factor of the device in babylon space
  19209. */
  19210. deviceScaleFactor: number;
  19211. /**
  19212. * (Likely devicePosition should be used instead) The device position in its room space
  19213. */
  19214. position: Vector3;
  19215. /**
  19216. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19217. */
  19218. rotationQuaternion: Quaternion;
  19219. /**
  19220. * The type of controller (Eg. Windows mixed reality)
  19221. */
  19222. controllerType: PoseEnabledControllerType;
  19223. protected _calculatedPosition: Vector3;
  19224. private _calculatedRotation;
  19225. /**
  19226. * The raw pose from the device
  19227. */
  19228. rawPose: DevicePose;
  19229. private _trackPosition;
  19230. private _maxRotationDistFromHeadset;
  19231. private _draggedRoomRotation;
  19232. /**
  19233. * @hidden
  19234. */
  19235. _disableTrackPosition(fixedPosition: Vector3): void;
  19236. /**
  19237. * Internal, the mesh attached to the controller
  19238. * @hidden
  19239. */
  19240. _mesh: Nullable<AbstractMesh>;
  19241. private _poseControlledCamera;
  19242. private _leftHandSystemQuaternion;
  19243. /**
  19244. * Internal, matrix used to convert room space to babylon space
  19245. * @hidden
  19246. */
  19247. _deviceToWorld: Matrix;
  19248. /**
  19249. * Node to be used when casting a ray from the controller
  19250. * @hidden
  19251. */
  19252. _pointingPoseNode: Nullable<TransformNode>;
  19253. /**
  19254. * Name of the child mesh that can be used to cast a ray from the controller
  19255. */
  19256. static readonly POINTING_POSE: string;
  19257. /**
  19258. * Creates a new PoseEnabledController from a gamepad
  19259. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19260. */
  19261. constructor(browserGamepad: any);
  19262. private _workingMatrix;
  19263. /**
  19264. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19265. */
  19266. update(): void;
  19267. /**
  19268. * Updates only the pose device and mesh without doing any button event checking
  19269. */
  19270. protected _updatePoseAndMesh(): void;
  19271. /**
  19272. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19273. * @param poseData raw pose fromthe device
  19274. */
  19275. updateFromDevice(poseData: DevicePose): void;
  19276. /**
  19277. * @hidden
  19278. */
  19279. _meshAttachedObservable: Observable<AbstractMesh>;
  19280. /**
  19281. * Attaches a mesh to the controller
  19282. * @param mesh the mesh to be attached
  19283. */
  19284. attachToMesh(mesh: AbstractMesh): void;
  19285. /**
  19286. * Attaches the controllers mesh to a camera
  19287. * @param camera the camera the mesh should be attached to
  19288. */
  19289. attachToPoseControlledCamera(camera: TargetCamera): void;
  19290. /**
  19291. * Disposes of the controller
  19292. */
  19293. dispose(): void;
  19294. /**
  19295. * The mesh that is attached to the controller
  19296. */
  19297. get mesh(): Nullable<AbstractMesh>;
  19298. /**
  19299. * Gets the ray of the controller in the direction the controller is pointing
  19300. * @param length the length the resulting ray should be
  19301. * @returns a ray in the direction the controller is pointing
  19302. */
  19303. getForwardRay(length?: number): Ray;
  19304. }
  19305. }
  19306. declare module BABYLON {
  19307. /**
  19308. * Defines the WebVRController object that represents controllers tracked in 3D space
  19309. */
  19310. export abstract class WebVRController extends PoseEnabledController {
  19311. /**
  19312. * Internal, the default controller model for the controller
  19313. */
  19314. protected _defaultModel: Nullable<AbstractMesh>;
  19315. /**
  19316. * Fired when the trigger state has changed
  19317. */
  19318. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19319. /**
  19320. * Fired when the main button state has changed
  19321. */
  19322. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19323. /**
  19324. * Fired when the secondary button state has changed
  19325. */
  19326. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19327. /**
  19328. * Fired when the pad state has changed
  19329. */
  19330. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19331. /**
  19332. * Fired when controllers stick values have changed
  19333. */
  19334. onPadValuesChangedObservable: Observable<StickValues>;
  19335. /**
  19336. * Array of button availible on the controller
  19337. */
  19338. protected _buttons: Array<MutableGamepadButton>;
  19339. private _onButtonStateChange;
  19340. /**
  19341. * Fired when a controller button's state has changed
  19342. * @param callback the callback containing the button that was modified
  19343. */
  19344. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19345. /**
  19346. * X and Y axis corresponding to the controllers joystick
  19347. */
  19348. pad: StickValues;
  19349. /**
  19350. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19351. */
  19352. hand: string;
  19353. /**
  19354. * The default controller model for the controller
  19355. */
  19356. get defaultModel(): Nullable<AbstractMesh>;
  19357. /**
  19358. * Creates a new WebVRController from a gamepad
  19359. * @param vrGamepad the gamepad that the WebVRController should be created from
  19360. */
  19361. constructor(vrGamepad: any);
  19362. /**
  19363. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19364. */
  19365. update(): void;
  19366. /**
  19367. * Function to be called when a button is modified
  19368. */
  19369. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19370. /**
  19371. * Loads a mesh and attaches it to the controller
  19372. * @param scene the scene the mesh should be added to
  19373. * @param meshLoaded callback for when the mesh has been loaded
  19374. */
  19375. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19376. private _setButtonValue;
  19377. private _changes;
  19378. private _checkChanges;
  19379. /**
  19380. * Disposes of th webVRCOntroller
  19381. */
  19382. dispose(): void;
  19383. }
  19384. }
  19385. declare module BABYLON {
  19386. /**
  19387. * The HemisphericLight simulates the ambient environment light,
  19388. * so the passed direction is the light reflection direction, not the incoming direction.
  19389. */
  19390. export class HemisphericLight extends Light {
  19391. /**
  19392. * The groundColor is the light in the opposite direction to the one specified during creation.
  19393. * 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.
  19394. */
  19395. groundColor: Color3;
  19396. /**
  19397. * The light reflection direction, not the incoming direction.
  19398. */
  19399. direction: Vector3;
  19400. /**
  19401. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19402. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19403. * The HemisphericLight can't cast shadows.
  19404. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19405. * @param name The friendly name of the light
  19406. * @param direction The direction of the light reflection
  19407. * @param scene The scene the light belongs to
  19408. */
  19409. constructor(name: string, direction: Vector3, scene: Scene);
  19410. protected _buildUniformLayout(): void;
  19411. /**
  19412. * Returns the string "HemisphericLight".
  19413. * @return The class name
  19414. */
  19415. getClassName(): string;
  19416. /**
  19417. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19418. * Returns the updated direction.
  19419. * @param target The target the direction should point to
  19420. * @return The computed direction
  19421. */
  19422. setDirectionToTarget(target: Vector3): Vector3;
  19423. /**
  19424. * Returns the shadow generator associated to the light.
  19425. * @returns Always null for hemispheric lights because it does not support shadows.
  19426. */
  19427. getShadowGenerator(): Nullable<IShadowGenerator>;
  19428. /**
  19429. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19430. * @param effect The effect to update
  19431. * @param lightIndex The index of the light in the effect to update
  19432. * @returns The hemispheric light
  19433. */
  19434. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19435. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19436. /**
  19437. * Computes the world matrix of the node
  19438. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19439. * @param useWasUpdatedFlag defines a reserved property
  19440. * @returns the world matrix
  19441. */
  19442. computeWorldMatrix(): Matrix;
  19443. /**
  19444. * Returns the integer 3.
  19445. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19446. */
  19447. getTypeID(): number;
  19448. /**
  19449. * Prepares the list of defines specific to the light type.
  19450. * @param defines the list of defines
  19451. * @param lightIndex defines the index of the light for the effect
  19452. */
  19453. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19454. }
  19455. }
  19456. declare module BABYLON {
  19457. /** @hidden */
  19458. export var vrMultiviewToSingleviewPixelShader: {
  19459. name: string;
  19460. shader: string;
  19461. };
  19462. }
  19463. declare module BABYLON {
  19464. /**
  19465. * Renders to multiple views with a single draw call
  19466. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19467. */
  19468. export class MultiviewRenderTarget extends RenderTargetTexture {
  19469. /**
  19470. * Creates a multiview render target
  19471. * @param scene scene used with the render target
  19472. * @param size the size of the render target (used for each view)
  19473. */
  19474. constructor(scene: Scene, size?: number | {
  19475. width: number;
  19476. height: number;
  19477. } | {
  19478. ratio: number;
  19479. });
  19480. /**
  19481. * @hidden
  19482. * @param faceIndex the face index, if its a cube texture
  19483. */
  19484. _bindFrameBuffer(faceIndex?: number): void;
  19485. /**
  19486. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19487. * @returns the view count
  19488. */
  19489. getViewCount(): number;
  19490. }
  19491. }
  19492. declare module BABYLON {
  19493. interface Engine {
  19494. /**
  19495. * Creates a new multiview render target
  19496. * @param width defines the width of the texture
  19497. * @param height defines the height of the texture
  19498. * @returns the created multiview texture
  19499. */
  19500. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19501. /**
  19502. * Binds a multiview framebuffer to be drawn to
  19503. * @param multiviewTexture texture to bind
  19504. */
  19505. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19506. }
  19507. interface Camera {
  19508. /**
  19509. * @hidden
  19510. * 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)
  19511. */
  19512. _useMultiviewToSingleView: boolean;
  19513. /**
  19514. * @hidden
  19515. * 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)
  19516. */
  19517. _multiviewTexture: Nullable<RenderTargetTexture>;
  19518. /**
  19519. * @hidden
  19520. * ensures the multiview texture of the camera exists and has the specified width/height
  19521. * @param width height to set on the multiview texture
  19522. * @param height width to set on the multiview texture
  19523. */
  19524. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19525. }
  19526. interface Scene {
  19527. /** @hidden */
  19528. _transformMatrixR: Matrix;
  19529. /** @hidden */
  19530. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19531. /** @hidden */
  19532. _createMultiviewUbo(): void;
  19533. /** @hidden */
  19534. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19535. /** @hidden */
  19536. _renderMultiviewToSingleView(camera: Camera): void;
  19537. }
  19538. }
  19539. declare module BABYLON {
  19540. /**
  19541. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19542. * This will not be used for webXR as it supports displaying texture arrays directly
  19543. */
  19544. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19545. /**
  19546. * Initializes a VRMultiviewToSingleview
  19547. * @param name name of the post process
  19548. * @param camera camera to be applied to
  19549. * @param scaleFactor scaling factor to the size of the output texture
  19550. */
  19551. constructor(name: string, camera: Camera, scaleFactor: number);
  19552. }
  19553. }
  19554. declare module BABYLON {
  19555. /**
  19556. * Interface used to define additional presentation attributes
  19557. */
  19558. export interface IVRPresentationAttributes {
  19559. /**
  19560. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19561. */
  19562. highRefreshRate: boolean;
  19563. /**
  19564. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19565. */
  19566. foveationLevel: number;
  19567. }
  19568. interface Engine {
  19569. /** @hidden */
  19570. _vrDisplay: any;
  19571. /** @hidden */
  19572. _vrSupported: boolean;
  19573. /** @hidden */
  19574. _oldSize: Size;
  19575. /** @hidden */
  19576. _oldHardwareScaleFactor: number;
  19577. /** @hidden */
  19578. _vrExclusivePointerMode: boolean;
  19579. /** @hidden */
  19580. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19581. /** @hidden */
  19582. _onVRDisplayPointerRestricted: () => void;
  19583. /** @hidden */
  19584. _onVRDisplayPointerUnrestricted: () => void;
  19585. /** @hidden */
  19586. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19587. /** @hidden */
  19588. _onVrDisplayDisconnect: Nullable<() => void>;
  19589. /** @hidden */
  19590. _onVrDisplayPresentChange: Nullable<() => void>;
  19591. /**
  19592. * Observable signaled when VR display mode changes
  19593. */
  19594. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19595. /**
  19596. * Observable signaled when VR request present is complete
  19597. */
  19598. onVRRequestPresentComplete: Observable<boolean>;
  19599. /**
  19600. * Observable signaled when VR request present starts
  19601. */
  19602. onVRRequestPresentStart: Observable<Engine>;
  19603. /**
  19604. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19605. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19606. */
  19607. isInVRExclusivePointerMode: boolean;
  19608. /**
  19609. * Gets a boolean indicating if a webVR device was detected
  19610. * @returns true if a webVR device was detected
  19611. */
  19612. isVRDevicePresent(): boolean;
  19613. /**
  19614. * Gets the current webVR device
  19615. * @returns the current webVR device (or null)
  19616. */
  19617. getVRDevice(): any;
  19618. /**
  19619. * Initializes a webVR display and starts listening to display change events
  19620. * The onVRDisplayChangedObservable will be notified upon these changes
  19621. * @returns A promise containing a VRDisplay and if vr is supported
  19622. */
  19623. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19624. /** @hidden */
  19625. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19626. /**
  19627. * Gets or sets the presentation attributes used to configure VR rendering
  19628. */
  19629. vrPresentationAttributes?: IVRPresentationAttributes;
  19630. /**
  19631. * Call this function to switch to webVR mode
  19632. * Will do nothing if webVR is not supported or if there is no webVR device
  19633. * @param options the webvr options provided to the camera. mainly used for multiview
  19634. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19635. */
  19636. enableVR(options: WebVROptions): void;
  19637. /** @hidden */
  19638. _onVRFullScreenTriggered(): void;
  19639. }
  19640. }
  19641. declare module BABYLON {
  19642. /**
  19643. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19644. * IMPORTANT!! The data is right-hand data.
  19645. * @export
  19646. * @interface DevicePose
  19647. */
  19648. export interface DevicePose {
  19649. /**
  19650. * The position of the device, values in array are [x,y,z].
  19651. */
  19652. readonly position: Nullable<Float32Array>;
  19653. /**
  19654. * The linearVelocity of the device, values in array are [x,y,z].
  19655. */
  19656. readonly linearVelocity: Nullable<Float32Array>;
  19657. /**
  19658. * The linearAcceleration of the device, values in array are [x,y,z].
  19659. */
  19660. readonly linearAcceleration: Nullable<Float32Array>;
  19661. /**
  19662. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19663. */
  19664. readonly orientation: Nullable<Float32Array>;
  19665. /**
  19666. * The angularVelocity of the device, values in array are [x,y,z].
  19667. */
  19668. readonly angularVelocity: Nullable<Float32Array>;
  19669. /**
  19670. * The angularAcceleration of the device, values in array are [x,y,z].
  19671. */
  19672. readonly angularAcceleration: Nullable<Float32Array>;
  19673. }
  19674. /**
  19675. * Interface representing a pose controlled object in Babylon.
  19676. * A pose controlled object has both regular pose values as well as pose values
  19677. * from an external device such as a VR head mounted display
  19678. */
  19679. export interface PoseControlled {
  19680. /**
  19681. * The position of the object in babylon space.
  19682. */
  19683. position: Vector3;
  19684. /**
  19685. * The rotation quaternion of the object in babylon space.
  19686. */
  19687. rotationQuaternion: Quaternion;
  19688. /**
  19689. * The position of the device in babylon space.
  19690. */
  19691. devicePosition?: Vector3;
  19692. /**
  19693. * The rotation quaternion of the device in babylon space.
  19694. */
  19695. deviceRotationQuaternion: Quaternion;
  19696. /**
  19697. * The raw pose coming from the device.
  19698. */
  19699. rawPose: Nullable<DevicePose>;
  19700. /**
  19701. * The scale of the device to be used when translating from device space to babylon space.
  19702. */
  19703. deviceScaleFactor: number;
  19704. /**
  19705. * Updates the poseControlled values based on the input device pose.
  19706. * @param poseData the pose data to update the object with
  19707. */
  19708. updateFromDevice(poseData: DevicePose): void;
  19709. }
  19710. /**
  19711. * Set of options to customize the webVRCamera
  19712. */
  19713. export interface WebVROptions {
  19714. /**
  19715. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19716. */
  19717. trackPosition?: boolean;
  19718. /**
  19719. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19720. */
  19721. positionScale?: number;
  19722. /**
  19723. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19724. */
  19725. displayName?: string;
  19726. /**
  19727. * Should the native controller meshes be initialized. (default: true)
  19728. */
  19729. controllerMeshes?: boolean;
  19730. /**
  19731. * Creating a default HemiLight only on controllers. (default: true)
  19732. */
  19733. defaultLightingOnControllers?: boolean;
  19734. /**
  19735. * If you don't want to use the default VR button of the helper. (default: false)
  19736. */
  19737. useCustomVRButton?: boolean;
  19738. /**
  19739. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19740. */
  19741. customVRButton?: HTMLButtonElement;
  19742. /**
  19743. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19744. */
  19745. rayLength?: number;
  19746. /**
  19747. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19748. */
  19749. defaultHeight?: number;
  19750. /**
  19751. * If multiview should be used if availible (default: false)
  19752. */
  19753. useMultiview?: boolean;
  19754. }
  19755. /**
  19756. * This represents a WebVR camera.
  19757. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19758. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19759. */
  19760. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19761. private webVROptions;
  19762. /**
  19763. * @hidden
  19764. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19765. */
  19766. _vrDevice: any;
  19767. /**
  19768. * The rawPose of the vrDevice.
  19769. */
  19770. rawPose: Nullable<DevicePose>;
  19771. private _onVREnabled;
  19772. private _specsVersion;
  19773. private _attached;
  19774. private _frameData;
  19775. protected _descendants: Array<Node>;
  19776. private _deviceRoomPosition;
  19777. /** @hidden */
  19778. _deviceRoomRotationQuaternion: Quaternion;
  19779. private _standingMatrix;
  19780. /**
  19781. * Represents device position in babylon space.
  19782. */
  19783. devicePosition: Vector3;
  19784. /**
  19785. * Represents device rotation in babylon space.
  19786. */
  19787. deviceRotationQuaternion: Quaternion;
  19788. /**
  19789. * The scale of the device to be used when translating from device space to babylon space.
  19790. */
  19791. deviceScaleFactor: number;
  19792. private _deviceToWorld;
  19793. private _worldToDevice;
  19794. /**
  19795. * References to the webVR controllers for the vrDevice.
  19796. */
  19797. controllers: Array<WebVRController>;
  19798. /**
  19799. * Emits an event when a controller is attached.
  19800. */
  19801. onControllersAttachedObservable: Observable<WebVRController[]>;
  19802. /**
  19803. * Emits an event when a controller's mesh has been loaded;
  19804. */
  19805. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19806. /**
  19807. * Emits an event when the HMD's pose has been updated.
  19808. */
  19809. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19810. private _poseSet;
  19811. /**
  19812. * If the rig cameras be used as parent instead of this camera.
  19813. */
  19814. rigParenting: boolean;
  19815. private _lightOnControllers;
  19816. private _defaultHeight?;
  19817. /**
  19818. * Instantiates a WebVRFreeCamera.
  19819. * @param name The name of the WebVRFreeCamera
  19820. * @param position The starting anchor position for the camera
  19821. * @param scene The scene the camera belongs to
  19822. * @param webVROptions a set of customizable options for the webVRCamera
  19823. */
  19824. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19825. /**
  19826. * Gets the device distance from the ground in meters.
  19827. * @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.
  19828. */
  19829. deviceDistanceToRoomGround(): number;
  19830. /**
  19831. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19832. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19833. */
  19834. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19835. /**
  19836. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19837. * @returns A promise with a boolean set to if the standing matrix is supported.
  19838. */
  19839. useStandingMatrixAsync(): Promise<boolean>;
  19840. /**
  19841. * Disposes the camera
  19842. */
  19843. dispose(): void;
  19844. /**
  19845. * Gets a vrController by name.
  19846. * @param name The name of the controller to retreive
  19847. * @returns the controller matching the name specified or null if not found
  19848. */
  19849. getControllerByName(name: string): Nullable<WebVRController>;
  19850. private _leftController;
  19851. /**
  19852. * The controller corresponding to the users left hand.
  19853. */
  19854. get leftController(): Nullable<WebVRController>;
  19855. private _rightController;
  19856. /**
  19857. * The controller corresponding to the users right hand.
  19858. */
  19859. get rightController(): Nullable<WebVRController>;
  19860. /**
  19861. * Casts a ray forward from the vrCamera's gaze.
  19862. * @param length Length of the ray (default: 100)
  19863. * @returns the ray corresponding to the gaze
  19864. */
  19865. getForwardRay(length?: number): Ray;
  19866. /**
  19867. * @hidden
  19868. * Updates the camera based on device's frame data
  19869. */
  19870. _checkInputs(): void;
  19871. /**
  19872. * Updates the poseControlled values based on the input device pose.
  19873. * @param poseData Pose coming from the device
  19874. */
  19875. updateFromDevice(poseData: DevicePose): void;
  19876. private _htmlElementAttached;
  19877. private _detachIfAttached;
  19878. /**
  19879. * WebVR's attach control will start broadcasting frames to the device.
  19880. * Note that in certain browsers (chrome for example) this function must be called
  19881. * within a user-interaction callback. Example:
  19882. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19883. *
  19884. * @param element html element to attach the vrDevice to
  19885. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19886. */
  19887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19888. /**
  19889. * Detaches the camera from the html element and disables VR
  19890. *
  19891. * @param element html element to detach from
  19892. */
  19893. detachControl(element: HTMLElement): void;
  19894. /**
  19895. * @returns the name of this class
  19896. */
  19897. getClassName(): string;
  19898. /**
  19899. * Calls resetPose on the vrDisplay
  19900. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19901. */
  19902. resetToCurrentRotation(): void;
  19903. /**
  19904. * @hidden
  19905. * Updates the rig cameras (left and right eye)
  19906. */
  19907. _updateRigCameras(): void;
  19908. private _workingVector;
  19909. private _oneVector;
  19910. private _workingMatrix;
  19911. private updateCacheCalled;
  19912. private _correctPositionIfNotTrackPosition;
  19913. /**
  19914. * @hidden
  19915. * Updates the cached values of the camera
  19916. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19917. */
  19918. _updateCache(ignoreParentClass?: boolean): void;
  19919. /**
  19920. * @hidden
  19921. * Get current device position in babylon world
  19922. */
  19923. _computeDevicePosition(): void;
  19924. /**
  19925. * Updates the current device position and rotation in the babylon world
  19926. */
  19927. update(): void;
  19928. /**
  19929. * @hidden
  19930. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19931. * @returns an identity matrix
  19932. */
  19933. _getViewMatrix(): Matrix;
  19934. private _tmpMatrix;
  19935. /**
  19936. * This function is called by the two RIG cameras.
  19937. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19938. * @hidden
  19939. */
  19940. _getWebVRViewMatrix(): Matrix;
  19941. /** @hidden */
  19942. _getWebVRProjectionMatrix(): Matrix;
  19943. private _onGamepadConnectedObserver;
  19944. private _onGamepadDisconnectedObserver;
  19945. private _updateCacheWhenTrackingDisabledObserver;
  19946. /**
  19947. * Initializes the controllers and their meshes
  19948. */
  19949. initControllers(): void;
  19950. }
  19951. }
  19952. declare module BABYLON {
  19953. /**
  19954. * "Static Class" containing the most commonly used helper while dealing with material for
  19955. * rendering purpose.
  19956. *
  19957. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19958. *
  19959. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19960. */
  19961. export class MaterialHelper {
  19962. /**
  19963. * Bind the current view position to an effect.
  19964. * @param effect The effect to be bound
  19965. * @param scene The scene the eyes position is used from
  19966. * @param variableName name of the shader variable that will hold the eye position
  19967. */
  19968. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19969. /**
  19970. * Helps preparing the defines values about the UVs in used in the effect.
  19971. * UVs are shared as much as we can accross channels in the shaders.
  19972. * @param texture The texture we are preparing the UVs for
  19973. * @param defines The defines to update
  19974. * @param key The channel key "diffuse", "specular"... used in the shader
  19975. */
  19976. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19977. /**
  19978. * Binds a texture matrix value to its corrsponding uniform
  19979. * @param texture The texture to bind the matrix for
  19980. * @param uniformBuffer The uniform buffer receivin the data
  19981. * @param key The channel key "diffuse", "specular"... used in the shader
  19982. */
  19983. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19984. /**
  19985. * Gets the current status of the fog (should it be enabled?)
  19986. * @param mesh defines the mesh to evaluate for fog support
  19987. * @param scene defines the hosting scene
  19988. * @returns true if fog must be enabled
  19989. */
  19990. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19991. /**
  19992. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19993. * @param mesh defines the current mesh
  19994. * @param scene defines the current scene
  19995. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19996. * @param pointsCloud defines if point cloud rendering has to be turned on
  19997. * @param fogEnabled defines if fog has to be turned on
  19998. * @param alphaTest defines if alpha testing has to be turned on
  19999. * @param defines defines the current list of defines
  20000. */
  20001. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20002. /**
  20003. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20004. * @param scene defines the current scene
  20005. * @param engine defines the current engine
  20006. * @param defines specifies the list of active defines
  20007. * @param useInstances defines if instances have to be turned on
  20008. * @param useClipPlane defines if clip plane have to be turned on
  20009. * @param useInstances defines if instances have to be turned on
  20010. * @param useThinInstances defines if thin instances have to be turned on
  20011. */
  20012. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20013. /**
  20014. * Prepares the defines for bones
  20015. * @param mesh The mesh containing the geometry data we will draw
  20016. * @param defines The defines to update
  20017. */
  20018. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20019. /**
  20020. * Prepares the defines for morph targets
  20021. * @param mesh The mesh containing the geometry data we will draw
  20022. * @param defines The defines to update
  20023. */
  20024. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20025. /**
  20026. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20027. * @param mesh The mesh containing the geometry data we will draw
  20028. * @param defines The defines to update
  20029. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20030. * @param useBones Precise whether bones should be used or not (override mesh info)
  20031. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20032. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20033. * @returns false if defines are considered not dirty and have not been checked
  20034. */
  20035. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20036. /**
  20037. * Prepares the defines related to multiview
  20038. * @param scene The scene we are intending to draw
  20039. * @param defines The defines to update
  20040. */
  20041. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20042. /**
  20043. * Prepares the defines related to the light information passed in parameter
  20044. * @param scene The scene we are intending to draw
  20045. * @param mesh The mesh the effect is compiling for
  20046. * @param light The light the effect is compiling for
  20047. * @param lightIndex The index of the light
  20048. * @param defines The defines to update
  20049. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20050. * @param state Defines the current state regarding what is needed (normals, etc...)
  20051. */
  20052. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20053. needNormals: boolean;
  20054. needRebuild: boolean;
  20055. shadowEnabled: boolean;
  20056. specularEnabled: boolean;
  20057. lightmapMode: boolean;
  20058. }): void;
  20059. /**
  20060. * Prepares the defines related to the light information passed in parameter
  20061. * @param scene The scene we are intending to draw
  20062. * @param mesh The mesh the effect is compiling for
  20063. * @param defines The defines to update
  20064. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20065. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20066. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20067. * @returns true if normals will be required for the rest of the effect
  20068. */
  20069. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20070. /**
  20071. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20072. * @param lightIndex defines the light index
  20073. * @param uniformsList The uniform list
  20074. * @param samplersList The sampler list
  20075. * @param projectedLightTexture defines if projected texture must be used
  20076. * @param uniformBuffersList defines an optional list of uniform buffers
  20077. */
  20078. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20079. /**
  20080. * Prepares the uniforms and samplers list to be used in the effect
  20081. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20082. * @param samplersList The sampler list
  20083. * @param defines The defines helping in the list generation
  20084. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20085. */
  20086. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20087. /**
  20088. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20089. * @param defines The defines to update while falling back
  20090. * @param fallbacks The authorized effect fallbacks
  20091. * @param maxSimultaneousLights The maximum number of lights allowed
  20092. * @param rank the current rank of the Effect
  20093. * @returns The newly affected rank
  20094. */
  20095. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20096. private static _TmpMorphInfluencers;
  20097. /**
  20098. * Prepares the list of attributes required for morph targets according to the effect defines.
  20099. * @param attribs The current list of supported attribs
  20100. * @param mesh The mesh to prepare the morph targets attributes for
  20101. * @param influencers The number of influencers
  20102. */
  20103. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20104. /**
  20105. * Prepares the list of attributes required for morph targets according to the effect defines.
  20106. * @param attribs The current list of supported attribs
  20107. * @param mesh The mesh to prepare the morph targets attributes for
  20108. * @param defines The current Defines of the effect
  20109. */
  20110. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20111. /**
  20112. * Prepares the list of attributes required for bones according to the effect defines.
  20113. * @param attribs The current list of supported attribs
  20114. * @param mesh The mesh to prepare the bones attributes for
  20115. * @param defines The current Defines of the effect
  20116. * @param fallbacks The current efffect fallback strategy
  20117. */
  20118. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20119. /**
  20120. * Check and prepare the list of attributes required for instances according to the effect defines.
  20121. * @param attribs The current list of supported attribs
  20122. * @param defines The current MaterialDefines of the effect
  20123. */
  20124. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20125. /**
  20126. * Add the list of attributes required for instances to the attribs array.
  20127. * @param attribs The current list of supported attribs
  20128. */
  20129. static PushAttributesForInstances(attribs: string[]): void;
  20130. /**
  20131. * Binds the light information to the effect.
  20132. * @param light The light containing the generator
  20133. * @param effect The effect we are binding the data to
  20134. * @param lightIndex The light index in the effect used to render
  20135. */
  20136. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20137. /**
  20138. * Binds the lights information from the scene to the effect for the given mesh.
  20139. * @param light Light to bind
  20140. * @param lightIndex Light index
  20141. * @param scene The scene where the light belongs to
  20142. * @param effect The effect we are binding the data to
  20143. * @param useSpecular Defines if specular is supported
  20144. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20145. */
  20146. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20147. /**
  20148. * Binds the lights 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 defines The generated defines for the effect
  20153. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20154. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20155. */
  20156. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20157. private static _tempFogColor;
  20158. /**
  20159. * Binds the fog information from the scene to the effect for the given mesh.
  20160. * @param scene The scene the lights belongs to
  20161. * @param mesh The mesh we are binding the information to render
  20162. * @param effect The effect we are binding the data to
  20163. * @param linearSpace Defines if the fog effect is applied in linear space
  20164. */
  20165. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20166. /**
  20167. * Binds the bones information from the mesh to the effect.
  20168. * @param mesh The mesh we are binding the information to render
  20169. * @param effect The effect we are binding the data to
  20170. */
  20171. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20172. /**
  20173. * Binds the morph targets information from the mesh to the effect.
  20174. * @param abstractMesh The mesh we are binding the information to render
  20175. * @param effect The effect we are binding the data to
  20176. */
  20177. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20178. /**
  20179. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20180. * @param defines The generated defines used in the effect
  20181. * @param effect The effect we are binding the data to
  20182. * @param scene The scene we are willing to render with logarithmic scale for
  20183. */
  20184. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20185. /**
  20186. * Binds the clip plane information from the scene to the effect.
  20187. * @param scene The scene the clip plane information are extracted from
  20188. * @param effect The effect we are binding the data to
  20189. */
  20190. static BindClipPlane(effect: Effect, scene: Scene): void;
  20191. }
  20192. }
  20193. declare module BABYLON {
  20194. /**
  20195. * Block used to expose an input value
  20196. */
  20197. export class InputBlock extends NodeMaterialBlock {
  20198. private _mode;
  20199. private _associatedVariableName;
  20200. private _storedValue;
  20201. private _valueCallback;
  20202. private _type;
  20203. private _animationType;
  20204. /** Gets or set a value used to limit the range of float values */
  20205. min: number;
  20206. /** Gets or set a value used to limit the range of float values */
  20207. max: number;
  20208. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20209. isBoolean: boolean;
  20210. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20211. matrixMode: number;
  20212. /** @hidden */
  20213. _systemValue: Nullable<NodeMaterialSystemValues>;
  20214. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20215. visibleInInspector: boolean;
  20216. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20217. isConstant: boolean;
  20218. /** Gets or sets the group to use to display this block in the Inspector */
  20219. groupInInspector: string;
  20220. /** Gets an observable raised when the value is changed */
  20221. onValueChangedObservable: Observable<InputBlock>;
  20222. /**
  20223. * Gets or sets the connection point type (default is float)
  20224. */
  20225. get type(): NodeMaterialBlockConnectionPointTypes;
  20226. /**
  20227. * Creates a new InputBlock
  20228. * @param name defines the block name
  20229. * @param target defines the target of that block (Vertex by default)
  20230. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20231. */
  20232. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20233. /**
  20234. * Gets the output component
  20235. */
  20236. get output(): NodeMaterialConnectionPoint;
  20237. /**
  20238. * Set the source of this connection point to a vertex attribute
  20239. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20240. * @returns the current connection point
  20241. */
  20242. setAsAttribute(attributeName?: string): InputBlock;
  20243. /**
  20244. * Set the source of this connection point to a system value
  20245. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20246. * @returns the current connection point
  20247. */
  20248. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20249. /**
  20250. * Gets or sets the value of that point.
  20251. * Please note that this value will be ignored if valueCallback is defined
  20252. */
  20253. get value(): any;
  20254. set value(value: any);
  20255. /**
  20256. * Gets or sets a callback used to get the value of that point.
  20257. * Please note that setting this value will force the connection point to ignore the value property
  20258. */
  20259. get valueCallback(): () => any;
  20260. set valueCallback(value: () => any);
  20261. /**
  20262. * Gets or sets the associated variable name in the shader
  20263. */
  20264. get associatedVariableName(): string;
  20265. set associatedVariableName(value: string);
  20266. /** Gets or sets the type of animation applied to the input */
  20267. get animationType(): AnimatedInputBlockTypes;
  20268. set animationType(value: AnimatedInputBlockTypes);
  20269. /**
  20270. * Gets a boolean indicating that this connection point not defined yet
  20271. */
  20272. get isUndefined(): boolean;
  20273. /**
  20274. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20275. * In this case the connection point name must be the name of the uniform to use.
  20276. * Can only be set on inputs
  20277. */
  20278. get isUniform(): boolean;
  20279. set isUniform(value: boolean);
  20280. /**
  20281. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20282. * In this case the connection point name must be the name of the attribute to use
  20283. * Can only be set on inputs
  20284. */
  20285. get isAttribute(): boolean;
  20286. set isAttribute(value: boolean);
  20287. /**
  20288. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20289. * Can only be set on exit points
  20290. */
  20291. get isVarying(): boolean;
  20292. set isVarying(value: boolean);
  20293. /**
  20294. * Gets a boolean indicating that the current connection point is a system value
  20295. */
  20296. get isSystemValue(): boolean;
  20297. /**
  20298. * Gets or sets the current well known value or null if not defined as a system value
  20299. */
  20300. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20301. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20302. /**
  20303. * Gets the current class name
  20304. * @returns the class name
  20305. */
  20306. getClassName(): string;
  20307. /**
  20308. * Animate the input if animationType !== None
  20309. * @param scene defines the rendering scene
  20310. */
  20311. animate(scene: Scene): void;
  20312. private _emitDefine;
  20313. initialize(state: NodeMaterialBuildState): void;
  20314. /**
  20315. * Set the input block to its default value (based on its type)
  20316. */
  20317. setDefaultValue(): void;
  20318. private _emitConstant;
  20319. /** @hidden */
  20320. get _noContextSwitch(): boolean;
  20321. private _emit;
  20322. /** @hidden */
  20323. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20324. /** @hidden */
  20325. _transmit(effect: Effect, scene: Scene): void;
  20326. protected _buildBlock(state: NodeMaterialBuildState): void;
  20327. protected _dumpPropertiesCode(): string;
  20328. dispose(): void;
  20329. serialize(): any;
  20330. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20331. }
  20332. }
  20333. declare module BABYLON {
  20334. /**
  20335. * Enum used to define the compatibility state between two connection points
  20336. */
  20337. export enum NodeMaterialConnectionPointCompatibilityStates {
  20338. /** Points are compatibles */
  20339. Compatible = 0,
  20340. /** Points are incompatible because of their types */
  20341. TypeIncompatible = 1,
  20342. /** Points are incompatible because of their targets (vertex vs fragment) */
  20343. TargetIncompatible = 2
  20344. }
  20345. /**
  20346. * Defines the direction of a connection point
  20347. */
  20348. export enum NodeMaterialConnectionPointDirection {
  20349. /** Input */
  20350. Input = 0,
  20351. /** Output */
  20352. Output = 1
  20353. }
  20354. /**
  20355. * Defines a connection point for a block
  20356. */
  20357. export class NodeMaterialConnectionPoint {
  20358. /** @hidden */
  20359. _ownerBlock: NodeMaterialBlock;
  20360. /** @hidden */
  20361. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20362. private _endpoints;
  20363. private _associatedVariableName;
  20364. private _direction;
  20365. /** @hidden */
  20366. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20367. /** @hidden */
  20368. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20369. private _type;
  20370. /** @hidden */
  20371. _enforceAssociatedVariableName: boolean;
  20372. /** Gets the direction of the point */
  20373. get direction(): NodeMaterialConnectionPointDirection;
  20374. /** Indicates that this connection point needs dual validation before being connected to another point */
  20375. needDualDirectionValidation: boolean;
  20376. /**
  20377. * Gets or sets the additional types supported by this connection point
  20378. */
  20379. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20380. /**
  20381. * Gets or sets the additional types excluded by this connection point
  20382. */
  20383. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20384. /**
  20385. * Observable triggered when this point is connected
  20386. */
  20387. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20388. /**
  20389. * Gets or sets the associated variable name in the shader
  20390. */
  20391. get associatedVariableName(): string;
  20392. set associatedVariableName(value: string);
  20393. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20394. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20395. /**
  20396. * Gets or sets the connection point type (default is float)
  20397. */
  20398. get type(): NodeMaterialBlockConnectionPointTypes;
  20399. set type(value: NodeMaterialBlockConnectionPointTypes);
  20400. /**
  20401. * Gets or sets the connection point name
  20402. */
  20403. name: string;
  20404. /**
  20405. * Gets or sets the connection point name
  20406. */
  20407. displayName: string;
  20408. /**
  20409. * Gets or sets a boolean indicating that this connection point can be omitted
  20410. */
  20411. isOptional: boolean;
  20412. /**
  20413. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20414. */
  20415. define: string;
  20416. /** @hidden */
  20417. _prioritizeVertex: boolean;
  20418. private _target;
  20419. /** Gets or sets the target of that connection point */
  20420. get target(): NodeMaterialBlockTargets;
  20421. set target(value: NodeMaterialBlockTargets);
  20422. /**
  20423. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20424. */
  20425. get isConnected(): boolean;
  20426. /**
  20427. * Gets a boolean indicating that the current point is connected to an input block
  20428. */
  20429. get isConnectedToInputBlock(): boolean;
  20430. /**
  20431. * Gets a the connected input block (if any)
  20432. */
  20433. get connectInputBlock(): Nullable<InputBlock>;
  20434. /** Get the other side of the connection (if any) */
  20435. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20436. /** Get the block that owns this connection point */
  20437. get ownerBlock(): NodeMaterialBlock;
  20438. /** Get the block connected on the other side of this connection (if any) */
  20439. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20440. /** Get the block connected on the endpoints of this connection (if any) */
  20441. get connectedBlocks(): Array<NodeMaterialBlock>;
  20442. /** Gets the list of connected endpoints */
  20443. get endpoints(): NodeMaterialConnectionPoint[];
  20444. /** Gets a boolean indicating if that output point is connected to at least one input */
  20445. get hasEndpoints(): boolean;
  20446. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20447. get isConnectedInVertexShader(): boolean;
  20448. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20449. get isConnectedInFragmentShader(): boolean;
  20450. /**
  20451. * Creates a block suitable to be used as an input for this input point.
  20452. * If null is returned, a block based on the point type will be created.
  20453. * @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
  20454. */
  20455. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20456. /**
  20457. * Creates a new connection point
  20458. * @param name defines the connection point name
  20459. * @param ownerBlock defines the block hosting this connection point
  20460. * @param direction defines the direction of the connection point
  20461. */
  20462. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20463. /**
  20464. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20465. * @returns the class name
  20466. */
  20467. getClassName(): string;
  20468. /**
  20469. * Gets a boolean indicating if the current point can be connected to another point
  20470. * @param connectionPoint defines the other connection point
  20471. * @returns a boolean
  20472. */
  20473. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20474. /**
  20475. * Gets a number indicating if the current point can be connected to another point
  20476. * @param connectionPoint defines the other connection point
  20477. * @returns a number defining the compatibility state
  20478. */
  20479. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20480. /**
  20481. * Connect this point to another connection point
  20482. * @param connectionPoint defines the other connection point
  20483. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20484. * @returns the current connection point
  20485. */
  20486. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20487. /**
  20488. * Disconnect this point from one of his endpoint
  20489. * @param endpoint defines the other connection point
  20490. * @returns the current connection point
  20491. */
  20492. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20493. /**
  20494. * Serializes this point in a JSON representation
  20495. * @param isInput defines if the connection point is an input (default is true)
  20496. * @returns the serialized point object
  20497. */
  20498. serialize(isInput?: boolean): any;
  20499. /**
  20500. * Release resources
  20501. */
  20502. dispose(): void;
  20503. }
  20504. }
  20505. declare module BABYLON {
  20506. /**
  20507. * Enum used to define the material modes
  20508. */
  20509. export enum NodeMaterialModes {
  20510. /** Regular material */
  20511. Material = 0,
  20512. /** For post process */
  20513. PostProcess = 1,
  20514. /** For particle system */
  20515. Particle = 2
  20516. }
  20517. }
  20518. declare module BABYLON {
  20519. /**
  20520. * Block used to read a texture from a sampler
  20521. */
  20522. export class TextureBlock extends NodeMaterialBlock {
  20523. private _defineName;
  20524. private _linearDefineName;
  20525. private _gammaDefineName;
  20526. private _tempTextureRead;
  20527. private _samplerName;
  20528. private _transformedUVName;
  20529. private _textureTransformName;
  20530. private _textureInfoName;
  20531. private _mainUVName;
  20532. private _mainUVDefineName;
  20533. private _fragmentOnly;
  20534. /**
  20535. * Gets or sets the texture associated with the node
  20536. */
  20537. texture: Nullable<Texture>;
  20538. /**
  20539. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20540. */
  20541. convertToGammaSpace: boolean;
  20542. /**
  20543. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20544. */
  20545. convertToLinearSpace: boolean;
  20546. /**
  20547. * Create a new TextureBlock
  20548. * @param name defines the block name
  20549. */
  20550. constructor(name: string, fragmentOnly?: boolean);
  20551. /**
  20552. * Gets the current class name
  20553. * @returns the class name
  20554. */
  20555. getClassName(): string;
  20556. /**
  20557. * Gets the uv input component
  20558. */
  20559. get uv(): NodeMaterialConnectionPoint;
  20560. /**
  20561. * Gets the rgba output component
  20562. */
  20563. get rgba(): NodeMaterialConnectionPoint;
  20564. /**
  20565. * Gets the rgb output component
  20566. */
  20567. get rgb(): NodeMaterialConnectionPoint;
  20568. /**
  20569. * Gets the r output component
  20570. */
  20571. get r(): NodeMaterialConnectionPoint;
  20572. /**
  20573. * Gets the g output component
  20574. */
  20575. get g(): NodeMaterialConnectionPoint;
  20576. /**
  20577. * Gets the b output component
  20578. */
  20579. get b(): NodeMaterialConnectionPoint;
  20580. /**
  20581. * Gets the a output component
  20582. */
  20583. get a(): NodeMaterialConnectionPoint;
  20584. get target(): NodeMaterialBlockTargets;
  20585. autoConfigure(material: NodeMaterial): void;
  20586. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20588. isReady(): boolean;
  20589. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20590. private get _isMixed();
  20591. private _injectVertexCode;
  20592. private _writeTextureRead;
  20593. private _writeOutput;
  20594. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20595. protected _dumpPropertiesCode(): string;
  20596. serialize(): any;
  20597. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20598. }
  20599. }
  20600. declare module BABYLON {
  20601. /** @hidden */
  20602. export var reflectionFunction: {
  20603. name: string;
  20604. shader: string;
  20605. };
  20606. }
  20607. declare module BABYLON {
  20608. /**
  20609. * Base block used to read a reflection texture from a sampler
  20610. */
  20611. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20612. /** @hidden */
  20613. _define3DName: string;
  20614. /** @hidden */
  20615. _defineCubicName: string;
  20616. /** @hidden */
  20617. _defineExplicitName: string;
  20618. /** @hidden */
  20619. _defineProjectionName: string;
  20620. /** @hidden */
  20621. _defineLocalCubicName: string;
  20622. /** @hidden */
  20623. _defineSphericalName: string;
  20624. /** @hidden */
  20625. _definePlanarName: string;
  20626. /** @hidden */
  20627. _defineEquirectangularName: string;
  20628. /** @hidden */
  20629. _defineMirroredEquirectangularFixedName: string;
  20630. /** @hidden */
  20631. _defineEquirectangularFixedName: string;
  20632. /** @hidden */
  20633. _defineSkyboxName: string;
  20634. /** @hidden */
  20635. _defineOppositeZ: string;
  20636. /** @hidden */
  20637. _cubeSamplerName: string;
  20638. /** @hidden */
  20639. _2DSamplerName: string;
  20640. protected _positionUVWName: string;
  20641. protected _directionWName: string;
  20642. protected _reflectionVectorName: string;
  20643. /** @hidden */
  20644. _reflectionCoordsName: string;
  20645. /** @hidden */
  20646. _reflectionMatrixName: string;
  20647. protected _reflectionColorName: string;
  20648. /**
  20649. * Gets or sets the texture associated with the node
  20650. */
  20651. texture: Nullable<BaseTexture>;
  20652. /**
  20653. * Create a new ReflectionTextureBaseBlock
  20654. * @param name defines the block name
  20655. */
  20656. constructor(name: string);
  20657. /**
  20658. * Gets the current class name
  20659. * @returns the class name
  20660. */
  20661. getClassName(): string;
  20662. /**
  20663. * Gets the world position input component
  20664. */
  20665. abstract get position(): NodeMaterialConnectionPoint;
  20666. /**
  20667. * Gets the world position input component
  20668. */
  20669. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20670. /**
  20671. * Gets the world normal input component
  20672. */
  20673. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20674. /**
  20675. * Gets the world input component
  20676. */
  20677. abstract get world(): NodeMaterialConnectionPoint;
  20678. /**
  20679. * Gets the camera (or eye) position component
  20680. */
  20681. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20682. /**
  20683. * Gets the view input component
  20684. */
  20685. abstract get view(): NodeMaterialConnectionPoint;
  20686. protected _getTexture(): Nullable<BaseTexture>;
  20687. autoConfigure(material: NodeMaterial): void;
  20688. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20689. isReady(): boolean;
  20690. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20691. /**
  20692. * Gets the code to inject in the vertex shader
  20693. * @param state current state of the node material building
  20694. * @returns the shader code
  20695. */
  20696. handleVertexSide(state: NodeMaterialBuildState): string;
  20697. /**
  20698. * Handles the inits for the fragment code path
  20699. * @param state node material build state
  20700. */
  20701. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20702. /**
  20703. * Generates the reflection coords code for the fragment code path
  20704. * @param worldNormalVarName name of the world normal variable
  20705. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20706. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20707. * @returns the shader code
  20708. */
  20709. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20710. /**
  20711. * Generates the reflection color code for the fragment code path
  20712. * @param lodVarName name of the lod variable
  20713. * @param swizzleLookupTexture swizzle to use for the final color variable
  20714. * @returns the shader code
  20715. */
  20716. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20717. /**
  20718. * Generates the code corresponding to the connected output points
  20719. * @param state node material build state
  20720. * @param varName name of the variable to output
  20721. * @returns the shader code
  20722. */
  20723. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20724. protected _buildBlock(state: NodeMaterialBuildState): this;
  20725. protected _dumpPropertiesCode(): string;
  20726. serialize(): any;
  20727. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20728. }
  20729. }
  20730. declare module BABYLON {
  20731. /**
  20732. * Defines a connection point to be used for points with a custom object type
  20733. */
  20734. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20735. private _blockType;
  20736. private _blockName;
  20737. private _nameForCheking?;
  20738. /**
  20739. * Creates a new connection point
  20740. * @param name defines the connection point name
  20741. * @param ownerBlock defines the block hosting this connection point
  20742. * @param direction defines the direction of the connection point
  20743. */
  20744. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20745. /**
  20746. * Gets a number indicating if the current point can be connected to another point
  20747. * @param connectionPoint defines the other connection point
  20748. * @returns a number defining the compatibility state
  20749. */
  20750. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20751. /**
  20752. * Creates a block suitable to be used as an input for this input point.
  20753. * If null is returned, a block based on the point type will be created.
  20754. * @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
  20755. */
  20756. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20757. }
  20758. }
  20759. declare module BABYLON {
  20760. /**
  20761. * Enum defining the type of properties that can be edited in the property pages in the NME
  20762. */
  20763. export enum PropertyTypeForEdition {
  20764. /** property is a boolean */
  20765. Boolean = 0,
  20766. /** property is a float */
  20767. Float = 1,
  20768. /** property is a Vector2 */
  20769. Vector2 = 2,
  20770. /** property is a list of values */
  20771. List = 3
  20772. }
  20773. /**
  20774. * Interface that defines an option in a variable of type list
  20775. */
  20776. export interface IEditablePropertyListOption {
  20777. /** label of the option */
  20778. "label": string;
  20779. /** value of the option */
  20780. "value": number;
  20781. }
  20782. /**
  20783. * Interface that defines the options available for an editable property
  20784. */
  20785. export interface IEditablePropertyOption {
  20786. /** min value */
  20787. "min"?: number;
  20788. /** max value */
  20789. "max"?: number;
  20790. /** notifiers: indicates which actions to take when the property is changed */
  20791. "notifiers"?: {
  20792. /** the material should be rebuilt */
  20793. "rebuild"?: boolean;
  20794. /** the preview should be updated */
  20795. "update"?: boolean;
  20796. };
  20797. /** list of the options for a variable of type list */
  20798. "options"?: IEditablePropertyListOption[];
  20799. }
  20800. /**
  20801. * Interface that describes an editable property
  20802. */
  20803. export interface IPropertyDescriptionForEdition {
  20804. /** name of the property */
  20805. "propertyName": string;
  20806. /** display name of the property */
  20807. "displayName": string;
  20808. /** type of the property */
  20809. "type": PropertyTypeForEdition;
  20810. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20811. "groupName": string;
  20812. /** options for the property */
  20813. "options": IEditablePropertyOption;
  20814. }
  20815. /**
  20816. * Decorator that flags a property in a node material block as being editable
  20817. */
  20818. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20819. }
  20820. declare module BABYLON {
  20821. /**
  20822. * Block used to implement the refraction part of the sub surface module of the PBR material
  20823. */
  20824. export class RefractionBlock extends NodeMaterialBlock {
  20825. /** @hidden */
  20826. _define3DName: string;
  20827. /** @hidden */
  20828. _refractionMatrixName: string;
  20829. /** @hidden */
  20830. _defineLODRefractionAlpha: string;
  20831. /** @hidden */
  20832. _defineLinearSpecularRefraction: string;
  20833. /** @hidden */
  20834. _defineOppositeZ: string;
  20835. /** @hidden */
  20836. _cubeSamplerName: string;
  20837. /** @hidden */
  20838. _2DSamplerName: string;
  20839. /** @hidden */
  20840. _vRefractionMicrosurfaceInfosName: string;
  20841. /** @hidden */
  20842. _vRefractionInfosName: string;
  20843. private _scene;
  20844. /**
  20845. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20846. * Materials half opaque for instance using refraction could benefit from this control.
  20847. */
  20848. linkRefractionWithTransparency: boolean;
  20849. /**
  20850. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20851. */
  20852. invertRefractionY: boolean;
  20853. /**
  20854. * Gets or sets the texture associated with the node
  20855. */
  20856. texture: Nullable<BaseTexture>;
  20857. /**
  20858. * Create a new RefractionBlock
  20859. * @param name defines the block name
  20860. */
  20861. constructor(name: string);
  20862. /**
  20863. * Gets the current class name
  20864. * @returns the class name
  20865. */
  20866. getClassName(): string;
  20867. /**
  20868. * Gets the intensity input component
  20869. */
  20870. get intensity(): NodeMaterialConnectionPoint;
  20871. /**
  20872. * Gets the index of refraction input component
  20873. */
  20874. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20875. /**
  20876. * Gets the tint at distance input component
  20877. */
  20878. get tintAtDistance(): NodeMaterialConnectionPoint;
  20879. /**
  20880. * Gets the view input component
  20881. */
  20882. get view(): NodeMaterialConnectionPoint;
  20883. /**
  20884. * Gets the refraction object output component
  20885. */
  20886. get refraction(): NodeMaterialConnectionPoint;
  20887. /**
  20888. * Returns true if the block has a texture
  20889. */
  20890. get hasTexture(): boolean;
  20891. protected _getTexture(): Nullable<BaseTexture>;
  20892. autoConfigure(material: NodeMaterial): void;
  20893. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20894. isReady(): boolean;
  20895. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20896. /**
  20897. * Gets the main code of the block (fragment side)
  20898. * @param state current state of the node material building
  20899. * @returns the shader code
  20900. */
  20901. getCode(state: NodeMaterialBuildState): string;
  20902. protected _buildBlock(state: NodeMaterialBuildState): this;
  20903. protected _dumpPropertiesCode(): string;
  20904. serialize(): any;
  20905. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20906. }
  20907. }
  20908. declare module BABYLON {
  20909. /**
  20910. * Base block used as input for post process
  20911. */
  20912. export class CurrentScreenBlock extends NodeMaterialBlock {
  20913. private _samplerName;
  20914. private _linearDefineName;
  20915. private _gammaDefineName;
  20916. private _mainUVName;
  20917. private _tempTextureRead;
  20918. /**
  20919. * Gets or sets the texture associated with the node
  20920. */
  20921. texture: Nullable<BaseTexture>;
  20922. /**
  20923. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20924. */
  20925. convertToGammaSpace: boolean;
  20926. /**
  20927. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20928. */
  20929. convertToLinearSpace: boolean;
  20930. /**
  20931. * Create a new CurrentScreenBlock
  20932. * @param name defines the block name
  20933. */
  20934. constructor(name: string);
  20935. /**
  20936. * Gets the current class name
  20937. * @returns the class name
  20938. */
  20939. getClassName(): string;
  20940. /**
  20941. * Gets the uv input component
  20942. */
  20943. get uv(): NodeMaterialConnectionPoint;
  20944. /**
  20945. * Gets the rgba output component
  20946. */
  20947. get rgba(): NodeMaterialConnectionPoint;
  20948. /**
  20949. * Gets the rgb output component
  20950. */
  20951. get rgb(): NodeMaterialConnectionPoint;
  20952. /**
  20953. * Gets the r output component
  20954. */
  20955. get r(): NodeMaterialConnectionPoint;
  20956. /**
  20957. * Gets the g output component
  20958. */
  20959. get g(): NodeMaterialConnectionPoint;
  20960. /**
  20961. * Gets the b output component
  20962. */
  20963. get b(): NodeMaterialConnectionPoint;
  20964. /**
  20965. * Gets the a output component
  20966. */
  20967. get a(): NodeMaterialConnectionPoint;
  20968. /**
  20969. * Initialize the block and prepare the context for build
  20970. * @param state defines the state that will be used for the build
  20971. */
  20972. initialize(state: NodeMaterialBuildState): void;
  20973. get target(): NodeMaterialBlockTargets;
  20974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20975. isReady(): boolean;
  20976. private _injectVertexCode;
  20977. private _writeTextureRead;
  20978. private _writeOutput;
  20979. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20980. serialize(): any;
  20981. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20982. }
  20983. }
  20984. declare module BABYLON {
  20985. /**
  20986. * Base block used for the particle texture
  20987. */
  20988. export class ParticleTextureBlock extends NodeMaterialBlock {
  20989. private _samplerName;
  20990. private _linearDefineName;
  20991. private _gammaDefineName;
  20992. private _tempTextureRead;
  20993. /**
  20994. * Gets or sets the texture associated with the node
  20995. */
  20996. texture: Nullable<BaseTexture>;
  20997. /**
  20998. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20999. */
  21000. convertToGammaSpace: boolean;
  21001. /**
  21002. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21003. */
  21004. convertToLinearSpace: boolean;
  21005. /**
  21006. * Create a new ParticleTextureBlock
  21007. * @param name defines the block name
  21008. */
  21009. constructor(name: string);
  21010. /**
  21011. * Gets the current class name
  21012. * @returns the class name
  21013. */
  21014. getClassName(): string;
  21015. /**
  21016. * Gets the uv input component
  21017. */
  21018. get uv(): NodeMaterialConnectionPoint;
  21019. /**
  21020. * Gets the rgba output component
  21021. */
  21022. get rgba(): NodeMaterialConnectionPoint;
  21023. /**
  21024. * Gets the rgb output component
  21025. */
  21026. get rgb(): NodeMaterialConnectionPoint;
  21027. /**
  21028. * Gets the r output component
  21029. */
  21030. get r(): NodeMaterialConnectionPoint;
  21031. /**
  21032. * Gets the g output component
  21033. */
  21034. get g(): NodeMaterialConnectionPoint;
  21035. /**
  21036. * Gets the b output component
  21037. */
  21038. get b(): NodeMaterialConnectionPoint;
  21039. /**
  21040. * Gets the a output component
  21041. */
  21042. get a(): NodeMaterialConnectionPoint;
  21043. /**
  21044. * Initialize the block and prepare the context for build
  21045. * @param state defines the state that will be used for the build
  21046. */
  21047. initialize(state: NodeMaterialBuildState): void;
  21048. autoConfigure(material: NodeMaterial): void;
  21049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21050. isReady(): boolean;
  21051. private _writeOutput;
  21052. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21053. serialize(): any;
  21054. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21055. }
  21056. }
  21057. declare module BABYLON {
  21058. /**
  21059. * Class used to store shared data between 2 NodeMaterialBuildState
  21060. */
  21061. export class NodeMaterialBuildStateSharedData {
  21062. /**
  21063. * Gets the list of emitted varyings
  21064. */
  21065. temps: string[];
  21066. /**
  21067. * Gets the list of emitted varyings
  21068. */
  21069. varyings: string[];
  21070. /**
  21071. * Gets the varying declaration string
  21072. */
  21073. varyingDeclaration: string;
  21074. /**
  21075. * Input blocks
  21076. */
  21077. inputBlocks: InputBlock[];
  21078. /**
  21079. * Input blocks
  21080. */
  21081. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21082. /**
  21083. * Bindable blocks (Blocks that need to set data to the effect)
  21084. */
  21085. bindableBlocks: NodeMaterialBlock[];
  21086. /**
  21087. * List of blocks that can provide a compilation fallback
  21088. */
  21089. blocksWithFallbacks: NodeMaterialBlock[];
  21090. /**
  21091. * List of blocks that can provide a define update
  21092. */
  21093. blocksWithDefines: NodeMaterialBlock[];
  21094. /**
  21095. * List of blocks that can provide a repeatable content
  21096. */
  21097. repeatableContentBlocks: NodeMaterialBlock[];
  21098. /**
  21099. * List of blocks that can provide a dynamic list of uniforms
  21100. */
  21101. dynamicUniformBlocks: NodeMaterialBlock[];
  21102. /**
  21103. * List of blocks that can block the isReady function for the material
  21104. */
  21105. blockingBlocks: NodeMaterialBlock[];
  21106. /**
  21107. * Gets the list of animated inputs
  21108. */
  21109. animatedInputs: InputBlock[];
  21110. /**
  21111. * Build Id used to avoid multiple recompilations
  21112. */
  21113. buildId: number;
  21114. /** List of emitted variables */
  21115. variableNames: {
  21116. [key: string]: number;
  21117. };
  21118. /** List of emitted defines */
  21119. defineNames: {
  21120. [key: string]: number;
  21121. };
  21122. /** Should emit comments? */
  21123. emitComments: boolean;
  21124. /** Emit build activity */
  21125. verbose: boolean;
  21126. /** Gets or sets the hosting scene */
  21127. scene: Scene;
  21128. /**
  21129. * Gets the compilation hints emitted at compilation time
  21130. */
  21131. hints: {
  21132. needWorldViewMatrix: boolean;
  21133. needWorldViewProjectionMatrix: boolean;
  21134. needAlphaBlending: boolean;
  21135. needAlphaTesting: boolean;
  21136. };
  21137. /**
  21138. * List of compilation checks
  21139. */
  21140. checks: {
  21141. emitVertex: boolean;
  21142. emitFragment: boolean;
  21143. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21144. };
  21145. /**
  21146. * Is vertex program allowed to be empty?
  21147. */
  21148. allowEmptyVertexProgram: boolean;
  21149. /** Creates a new shared data */
  21150. constructor();
  21151. /**
  21152. * Emits console errors and exceptions if there is a failing check
  21153. */
  21154. emitErrors(): void;
  21155. }
  21156. }
  21157. declare module BABYLON {
  21158. /**
  21159. * Class used to store node based material build state
  21160. */
  21161. export class NodeMaterialBuildState {
  21162. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21163. supportUniformBuffers: boolean;
  21164. /**
  21165. * Gets the list of emitted attributes
  21166. */
  21167. attributes: string[];
  21168. /**
  21169. * Gets the list of emitted uniforms
  21170. */
  21171. uniforms: string[];
  21172. /**
  21173. * Gets the list of emitted constants
  21174. */
  21175. constants: string[];
  21176. /**
  21177. * Gets the list of emitted samplers
  21178. */
  21179. samplers: string[];
  21180. /**
  21181. * Gets the list of emitted functions
  21182. */
  21183. functions: {
  21184. [key: string]: string;
  21185. };
  21186. /**
  21187. * Gets the list of emitted extensions
  21188. */
  21189. extensions: {
  21190. [key: string]: string;
  21191. };
  21192. /**
  21193. * Gets the target of the compilation state
  21194. */
  21195. target: NodeMaterialBlockTargets;
  21196. /**
  21197. * Gets the list of emitted counters
  21198. */
  21199. counters: {
  21200. [key: string]: number;
  21201. };
  21202. /**
  21203. * Shared data between multiple NodeMaterialBuildState instances
  21204. */
  21205. sharedData: NodeMaterialBuildStateSharedData;
  21206. /** @hidden */
  21207. _vertexState: NodeMaterialBuildState;
  21208. /** @hidden */
  21209. _attributeDeclaration: string;
  21210. /** @hidden */
  21211. _uniformDeclaration: string;
  21212. /** @hidden */
  21213. _constantDeclaration: string;
  21214. /** @hidden */
  21215. _samplerDeclaration: string;
  21216. /** @hidden */
  21217. _varyingTransfer: string;
  21218. /** @hidden */
  21219. _injectAtEnd: string;
  21220. private _repeatableContentAnchorIndex;
  21221. /** @hidden */
  21222. _builtCompilationString: string;
  21223. /**
  21224. * Gets the emitted compilation strings
  21225. */
  21226. compilationString: string;
  21227. /**
  21228. * Finalize the compilation strings
  21229. * @param state defines the current compilation state
  21230. */
  21231. finalize(state: NodeMaterialBuildState): void;
  21232. /** @hidden */
  21233. get _repeatableContentAnchor(): string;
  21234. /** @hidden */
  21235. _getFreeVariableName(prefix: string): string;
  21236. /** @hidden */
  21237. _getFreeDefineName(prefix: string): string;
  21238. /** @hidden */
  21239. _excludeVariableName(name: string): void;
  21240. /** @hidden */
  21241. _emit2DSampler(name: string): void;
  21242. /** @hidden */
  21243. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21244. /** @hidden */
  21245. _emitExtension(name: string, extension: string, define?: string): void;
  21246. /** @hidden */
  21247. _emitFunction(name: string, code: string, comments: string): void;
  21248. /** @hidden */
  21249. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21250. replaceStrings?: {
  21251. search: RegExp;
  21252. replace: string;
  21253. }[];
  21254. repeatKey?: string;
  21255. }): string;
  21256. /** @hidden */
  21257. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21258. repeatKey?: string;
  21259. removeAttributes?: boolean;
  21260. removeUniforms?: boolean;
  21261. removeVaryings?: boolean;
  21262. removeIfDef?: boolean;
  21263. replaceStrings?: {
  21264. search: RegExp;
  21265. replace: string;
  21266. }[];
  21267. }, storeKey?: string): void;
  21268. /** @hidden */
  21269. _registerTempVariable(name: string): boolean;
  21270. /** @hidden */
  21271. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21272. /** @hidden */
  21273. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21274. /** @hidden */
  21275. _emitFloat(value: number): string;
  21276. }
  21277. }
  21278. declare module BABYLON {
  21279. /**
  21280. * Helper class used to generate session unique ID
  21281. */
  21282. export class UniqueIdGenerator {
  21283. private static _UniqueIdCounter;
  21284. /**
  21285. * Gets an unique (relatively to the current scene) Id
  21286. */
  21287. static get UniqueId(): number;
  21288. }
  21289. }
  21290. declare module BABYLON {
  21291. /**
  21292. * Defines a block that can be used inside a node based material
  21293. */
  21294. export class NodeMaterialBlock {
  21295. private _buildId;
  21296. private _buildTarget;
  21297. private _target;
  21298. private _isFinalMerger;
  21299. private _isInput;
  21300. protected _isUnique: boolean;
  21301. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21302. inputsAreExclusive: boolean;
  21303. /** @hidden */
  21304. _codeVariableName: string;
  21305. /** @hidden */
  21306. _inputs: NodeMaterialConnectionPoint[];
  21307. /** @hidden */
  21308. _outputs: NodeMaterialConnectionPoint[];
  21309. /** @hidden */
  21310. _preparationId: number;
  21311. /**
  21312. * Gets or sets the name of the block
  21313. */
  21314. name: string;
  21315. /**
  21316. * Gets or sets the unique id of the node
  21317. */
  21318. uniqueId: number;
  21319. /**
  21320. * Gets or sets the comments associated with this block
  21321. */
  21322. comments: string;
  21323. /**
  21324. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21325. */
  21326. get isUnique(): boolean;
  21327. /**
  21328. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21329. */
  21330. get isFinalMerger(): boolean;
  21331. /**
  21332. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21333. */
  21334. get isInput(): boolean;
  21335. /**
  21336. * Gets or sets the build Id
  21337. */
  21338. get buildId(): number;
  21339. set buildId(value: number);
  21340. /**
  21341. * Gets or sets the target of the block
  21342. */
  21343. get target(): NodeMaterialBlockTargets;
  21344. set target(value: NodeMaterialBlockTargets);
  21345. /**
  21346. * Gets the list of input points
  21347. */
  21348. get inputs(): NodeMaterialConnectionPoint[];
  21349. /** Gets the list of output points */
  21350. get outputs(): NodeMaterialConnectionPoint[];
  21351. /**
  21352. * Find an input by its name
  21353. * @param name defines the name of the input to look for
  21354. * @returns the input or null if not found
  21355. */
  21356. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21357. /**
  21358. * Find an output by its name
  21359. * @param name defines the name of the outputto look for
  21360. * @returns the output or null if not found
  21361. */
  21362. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21363. /**
  21364. * Creates a new NodeMaterialBlock
  21365. * @param name defines the block name
  21366. * @param target defines the target of that block (Vertex by default)
  21367. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21368. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21369. */
  21370. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21371. /**
  21372. * Initialize the block and prepare the context for build
  21373. * @param state defines the state that will be used for the build
  21374. */
  21375. initialize(state: NodeMaterialBuildState): void;
  21376. /**
  21377. * Bind data to effect. Will only be called for blocks with isBindable === true
  21378. * @param effect defines the effect to bind data to
  21379. * @param nodeMaterial defines the hosting NodeMaterial
  21380. * @param mesh defines the mesh that will be rendered
  21381. * @param subMesh defines the submesh that will be rendered
  21382. */
  21383. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21384. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21385. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21386. protected _writeFloat(value: number): string;
  21387. /**
  21388. * Gets the current class name e.g. "NodeMaterialBlock"
  21389. * @returns the class name
  21390. */
  21391. getClassName(): string;
  21392. /**
  21393. * Register a new input. Must be called inside a block constructor
  21394. * @param name defines the connection point name
  21395. * @param type defines the connection point type
  21396. * @param isOptional defines a boolean indicating that this input can be omitted
  21397. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21398. * @param point an already created connection point. If not provided, create a new one
  21399. * @returns the current block
  21400. */
  21401. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21402. /**
  21403. * Register a new output. Must be called inside a block constructor
  21404. * @param name defines the connection point name
  21405. * @param type defines the connection point type
  21406. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21407. * @param point an already created connection point. If not provided, create a new one
  21408. * @returns the current block
  21409. */
  21410. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21411. /**
  21412. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21413. * @param forOutput defines an optional connection point to check compatibility with
  21414. * @returns the first available input or null
  21415. */
  21416. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21417. /**
  21418. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21419. * @param forBlock defines an optional block to check compatibility with
  21420. * @returns the first available input or null
  21421. */
  21422. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21423. /**
  21424. * Gets the sibling of the given output
  21425. * @param current defines the current output
  21426. * @returns the next output in the list or null
  21427. */
  21428. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21429. /**
  21430. * Connect current block with another block
  21431. * @param other defines the block to connect with
  21432. * @param options define the various options to help pick the right connections
  21433. * @returns the current block
  21434. */
  21435. connectTo(other: NodeMaterialBlock, options?: {
  21436. input?: string;
  21437. output?: string;
  21438. outputSwizzle?: string;
  21439. }): this | undefined;
  21440. protected _buildBlock(state: NodeMaterialBuildState): void;
  21441. /**
  21442. * Add uniforms, samplers and uniform buffers at compilation time
  21443. * @param state defines the state to update
  21444. * @param nodeMaterial defines the node material requesting the update
  21445. * @param defines defines the material defines to update
  21446. * @param uniformBuffers defines the list of uniform buffer names
  21447. */
  21448. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21449. /**
  21450. * Add potential fallbacks if shader compilation fails
  21451. * @param mesh defines the mesh to be rendered
  21452. * @param fallbacks defines the current prioritized list of fallbacks
  21453. */
  21454. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21455. /**
  21456. * Initialize defines for shader compilation
  21457. * @param mesh defines the mesh to be rendered
  21458. * @param nodeMaterial defines the node material requesting the update
  21459. * @param defines defines the material defines to update
  21460. * @param useInstances specifies that instances should be used
  21461. */
  21462. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21463. /**
  21464. * Update defines for shader compilation
  21465. * @param mesh defines the mesh to be rendered
  21466. * @param nodeMaterial defines the node material requesting the update
  21467. * @param defines defines the material defines to update
  21468. * @param useInstances specifies that instances should be used
  21469. * @param subMesh defines which submesh to render
  21470. */
  21471. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21472. /**
  21473. * Lets the block try to connect some inputs automatically
  21474. * @param material defines the hosting NodeMaterial
  21475. */
  21476. autoConfigure(material: NodeMaterial): void;
  21477. /**
  21478. * Function called when a block is declared as repeatable content generator
  21479. * @param vertexShaderState defines the current compilation state for the vertex shader
  21480. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21481. * @param mesh defines the mesh to be rendered
  21482. * @param defines defines the material defines to update
  21483. */
  21484. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21485. /**
  21486. * Checks if the block is ready
  21487. * @param mesh defines the mesh to be rendered
  21488. * @param nodeMaterial defines the node material requesting the update
  21489. * @param defines defines the material defines to update
  21490. * @param useInstances specifies that instances should be used
  21491. * @returns true if the block is ready
  21492. */
  21493. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21494. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21495. private _processBuild;
  21496. /**
  21497. * Compile the current node and generate the shader code
  21498. * @param state defines the current compilation state (uniforms, samplers, current string)
  21499. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21500. * @returns true if already built
  21501. */
  21502. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21503. protected _inputRename(name: string): string;
  21504. protected _outputRename(name: string): string;
  21505. protected _dumpPropertiesCode(): string;
  21506. /** @hidden */
  21507. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21508. /** @hidden */
  21509. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21510. /**
  21511. * Clone the current block to a new identical block
  21512. * @param scene defines the hosting scene
  21513. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21514. * @returns a copy of the current block
  21515. */
  21516. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21517. /**
  21518. * Serializes this block in a JSON representation
  21519. * @returns the serialized block object
  21520. */
  21521. serialize(): any;
  21522. /** @hidden */
  21523. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21524. private _deserializePortDisplayNames;
  21525. /**
  21526. * Release resources
  21527. */
  21528. dispose(): void;
  21529. }
  21530. }
  21531. declare module BABYLON {
  21532. /**
  21533. * Base class of materials working in push mode in babylon JS
  21534. * @hidden
  21535. */
  21536. export class PushMaterial extends Material {
  21537. protected _activeEffect: Effect;
  21538. protected _normalMatrix: Matrix;
  21539. /**
  21540. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  21541. * This means that the material can keep using a previous shader while a new one is being compiled.
  21542. * This is mostly used when shader parallel compilation is supported (true by default)
  21543. */
  21544. allowShaderHotSwapping: boolean;
  21545. constructor(name: string, scene: Scene);
  21546. getEffect(): Effect;
  21547. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21548. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21549. /**
  21550. * Binds the given world matrix to the active effect
  21551. *
  21552. * @param world the matrix to bind
  21553. */
  21554. bindOnlyWorldMatrix(world: Matrix): void;
  21555. /**
  21556. * Binds the given normal matrix to the active effect
  21557. *
  21558. * @param normalMatrix the matrix to bind
  21559. */
  21560. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21561. bind(world: Matrix, mesh?: Mesh): void;
  21562. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21563. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21564. }
  21565. }
  21566. declare module BABYLON {
  21567. /**
  21568. * Root class for all node material optimizers
  21569. */
  21570. export class NodeMaterialOptimizer {
  21571. /**
  21572. * Function used to optimize a NodeMaterial graph
  21573. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21574. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21575. */
  21576. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21577. }
  21578. }
  21579. declare module BABYLON {
  21580. /**
  21581. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21582. */
  21583. export class TransformBlock extends NodeMaterialBlock {
  21584. /**
  21585. * Defines the value to use to complement W value to transform it to a Vector4
  21586. */
  21587. complementW: number;
  21588. /**
  21589. * Defines the value to use to complement z value to transform it to a Vector4
  21590. */
  21591. complementZ: number;
  21592. /**
  21593. * Creates a new TransformBlock
  21594. * @param name defines the block name
  21595. */
  21596. constructor(name: string);
  21597. /**
  21598. * Gets the current class name
  21599. * @returns the class name
  21600. */
  21601. getClassName(): string;
  21602. /**
  21603. * Gets the vector input
  21604. */
  21605. get vector(): NodeMaterialConnectionPoint;
  21606. /**
  21607. * Gets the output component
  21608. */
  21609. get output(): NodeMaterialConnectionPoint;
  21610. /**
  21611. * Gets the xyz output component
  21612. */
  21613. get xyz(): NodeMaterialConnectionPoint;
  21614. /**
  21615. * Gets the matrix transform input
  21616. */
  21617. get transform(): NodeMaterialConnectionPoint;
  21618. protected _buildBlock(state: NodeMaterialBuildState): this;
  21619. serialize(): any;
  21620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21621. protected _dumpPropertiesCode(): string;
  21622. }
  21623. }
  21624. declare module BABYLON {
  21625. /**
  21626. * Block used to output the vertex position
  21627. */
  21628. export class VertexOutputBlock extends NodeMaterialBlock {
  21629. /**
  21630. * Creates a new VertexOutputBlock
  21631. * @param name defines the block name
  21632. */
  21633. constructor(name: string);
  21634. /**
  21635. * Gets the current class name
  21636. * @returns the class name
  21637. */
  21638. getClassName(): string;
  21639. /**
  21640. * Gets the vector input component
  21641. */
  21642. get vector(): NodeMaterialConnectionPoint;
  21643. protected _buildBlock(state: NodeMaterialBuildState): this;
  21644. }
  21645. }
  21646. declare module BABYLON {
  21647. /**
  21648. * Block used to output the final color
  21649. */
  21650. export class FragmentOutputBlock extends NodeMaterialBlock {
  21651. /**
  21652. * Create a new FragmentOutputBlock
  21653. * @param name defines the block name
  21654. */
  21655. constructor(name: string);
  21656. /**
  21657. * Gets the current class name
  21658. * @returns the class name
  21659. */
  21660. getClassName(): string;
  21661. /**
  21662. * Gets the rgba input component
  21663. */
  21664. get rgba(): NodeMaterialConnectionPoint;
  21665. /**
  21666. * Gets the rgb input component
  21667. */
  21668. get rgb(): NodeMaterialConnectionPoint;
  21669. /**
  21670. * Gets the a input component
  21671. */
  21672. get a(): NodeMaterialConnectionPoint;
  21673. protected _buildBlock(state: NodeMaterialBuildState): this;
  21674. }
  21675. }
  21676. declare module BABYLON {
  21677. /**
  21678. * Block used for the particle ramp gradient section
  21679. */
  21680. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21681. /**
  21682. * Create a new ParticleRampGradientBlock
  21683. * @param name defines the block name
  21684. */
  21685. constructor(name: string);
  21686. /**
  21687. * Gets the current class name
  21688. * @returns the class name
  21689. */
  21690. getClassName(): string;
  21691. /**
  21692. * Gets the color input component
  21693. */
  21694. get color(): NodeMaterialConnectionPoint;
  21695. /**
  21696. * Gets the rampColor output component
  21697. */
  21698. get rampColor(): NodeMaterialConnectionPoint;
  21699. /**
  21700. * Initialize the block and prepare the context for build
  21701. * @param state defines the state that will be used for the build
  21702. */
  21703. initialize(state: NodeMaterialBuildState): void;
  21704. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21705. }
  21706. }
  21707. declare module BABYLON {
  21708. /**
  21709. * Block used for the particle blend multiply section
  21710. */
  21711. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21712. /**
  21713. * Create a new ParticleBlendMultiplyBlock
  21714. * @param name defines the block name
  21715. */
  21716. constructor(name: string);
  21717. /**
  21718. * Gets the current class name
  21719. * @returns the class name
  21720. */
  21721. getClassName(): string;
  21722. /**
  21723. * Gets the color input component
  21724. */
  21725. get color(): NodeMaterialConnectionPoint;
  21726. /**
  21727. * Gets the alphaTexture input component
  21728. */
  21729. get alphaTexture(): NodeMaterialConnectionPoint;
  21730. /**
  21731. * Gets the alphaColor input component
  21732. */
  21733. get alphaColor(): NodeMaterialConnectionPoint;
  21734. /**
  21735. * Gets the blendColor output component
  21736. */
  21737. get blendColor(): NodeMaterialConnectionPoint;
  21738. /**
  21739. * Initialize the block and prepare the context for build
  21740. * @param state defines the state that will be used for the build
  21741. */
  21742. initialize(state: NodeMaterialBuildState): void;
  21743. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21744. }
  21745. }
  21746. declare module BABYLON {
  21747. /**
  21748. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21749. */
  21750. export class VectorMergerBlock extends NodeMaterialBlock {
  21751. /**
  21752. * Create a new VectorMergerBlock
  21753. * @param name defines the block name
  21754. */
  21755. constructor(name: string);
  21756. /**
  21757. * Gets the current class name
  21758. * @returns the class name
  21759. */
  21760. getClassName(): string;
  21761. /**
  21762. * Gets the xyz component (input)
  21763. */
  21764. get xyzIn(): NodeMaterialConnectionPoint;
  21765. /**
  21766. * Gets the xy component (input)
  21767. */
  21768. get xyIn(): NodeMaterialConnectionPoint;
  21769. /**
  21770. * Gets the x component (input)
  21771. */
  21772. get x(): NodeMaterialConnectionPoint;
  21773. /**
  21774. * Gets the y component (input)
  21775. */
  21776. get y(): NodeMaterialConnectionPoint;
  21777. /**
  21778. * Gets the z component (input)
  21779. */
  21780. get z(): NodeMaterialConnectionPoint;
  21781. /**
  21782. * Gets the w component (input)
  21783. */
  21784. get w(): NodeMaterialConnectionPoint;
  21785. /**
  21786. * Gets the xyzw component (output)
  21787. */
  21788. get xyzw(): NodeMaterialConnectionPoint;
  21789. /**
  21790. * Gets the xyz component (output)
  21791. */
  21792. get xyzOut(): NodeMaterialConnectionPoint;
  21793. /**
  21794. * Gets the xy component (output)
  21795. */
  21796. get xyOut(): NodeMaterialConnectionPoint;
  21797. /**
  21798. * Gets the xy component (output)
  21799. * @deprecated Please use xyOut instead.
  21800. */
  21801. get xy(): NodeMaterialConnectionPoint;
  21802. /**
  21803. * Gets the xyz component (output)
  21804. * @deprecated Please use xyzOut instead.
  21805. */
  21806. get xyz(): NodeMaterialConnectionPoint;
  21807. protected _buildBlock(state: NodeMaterialBuildState): this;
  21808. }
  21809. }
  21810. declare module BABYLON {
  21811. /**
  21812. * Block used to remap a float from a range to a new one
  21813. */
  21814. export class RemapBlock extends NodeMaterialBlock {
  21815. /**
  21816. * Gets or sets the source range
  21817. */
  21818. sourceRange: Vector2;
  21819. /**
  21820. * Gets or sets the target range
  21821. */
  21822. targetRange: Vector2;
  21823. /**
  21824. * Creates a new RemapBlock
  21825. * @param name defines the block name
  21826. */
  21827. constructor(name: string);
  21828. /**
  21829. * Gets the current class name
  21830. * @returns the class name
  21831. */
  21832. getClassName(): string;
  21833. /**
  21834. * Gets the input component
  21835. */
  21836. get input(): NodeMaterialConnectionPoint;
  21837. /**
  21838. * Gets the source min input component
  21839. */
  21840. get sourceMin(): NodeMaterialConnectionPoint;
  21841. /**
  21842. * Gets the source max input component
  21843. */
  21844. get sourceMax(): NodeMaterialConnectionPoint;
  21845. /**
  21846. * Gets the target min input component
  21847. */
  21848. get targetMin(): NodeMaterialConnectionPoint;
  21849. /**
  21850. * Gets the target max input component
  21851. */
  21852. get targetMax(): NodeMaterialConnectionPoint;
  21853. /**
  21854. * Gets the output component
  21855. */
  21856. get output(): NodeMaterialConnectionPoint;
  21857. protected _buildBlock(state: NodeMaterialBuildState): this;
  21858. protected _dumpPropertiesCode(): string;
  21859. serialize(): any;
  21860. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21861. }
  21862. }
  21863. declare module BABYLON {
  21864. /**
  21865. * Block used to multiply 2 values
  21866. */
  21867. export class MultiplyBlock extends NodeMaterialBlock {
  21868. /**
  21869. * Creates a new MultiplyBlock
  21870. * @param name defines the block name
  21871. */
  21872. constructor(name: string);
  21873. /**
  21874. * Gets the current class name
  21875. * @returns the class name
  21876. */
  21877. getClassName(): string;
  21878. /**
  21879. * Gets the left operand input component
  21880. */
  21881. get left(): NodeMaterialConnectionPoint;
  21882. /**
  21883. * Gets the right operand input component
  21884. */
  21885. get right(): NodeMaterialConnectionPoint;
  21886. /**
  21887. * Gets the output component
  21888. */
  21889. get output(): NodeMaterialConnectionPoint;
  21890. protected _buildBlock(state: NodeMaterialBuildState): this;
  21891. }
  21892. }
  21893. declare module BABYLON {
  21894. /**
  21895. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21896. */
  21897. export class ColorSplitterBlock extends NodeMaterialBlock {
  21898. /**
  21899. * Create a new ColorSplitterBlock
  21900. * @param name defines the block name
  21901. */
  21902. constructor(name: string);
  21903. /**
  21904. * Gets the current class name
  21905. * @returns the class name
  21906. */
  21907. getClassName(): string;
  21908. /**
  21909. * Gets the rgba component (input)
  21910. */
  21911. get rgba(): NodeMaterialConnectionPoint;
  21912. /**
  21913. * Gets the rgb component (input)
  21914. */
  21915. get rgbIn(): NodeMaterialConnectionPoint;
  21916. /**
  21917. * Gets the rgb component (output)
  21918. */
  21919. get rgbOut(): NodeMaterialConnectionPoint;
  21920. /**
  21921. * Gets the r component (output)
  21922. */
  21923. get r(): NodeMaterialConnectionPoint;
  21924. /**
  21925. * Gets the g component (output)
  21926. */
  21927. get g(): NodeMaterialConnectionPoint;
  21928. /**
  21929. * Gets the b component (output)
  21930. */
  21931. get b(): NodeMaterialConnectionPoint;
  21932. /**
  21933. * Gets the a component (output)
  21934. */
  21935. get a(): NodeMaterialConnectionPoint;
  21936. protected _inputRename(name: string): string;
  21937. protected _outputRename(name: string): string;
  21938. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21939. }
  21940. }
  21941. declare module BABYLON {
  21942. /**
  21943. * Interface used to configure the node material editor
  21944. */
  21945. export interface INodeMaterialEditorOptions {
  21946. /** Define the URl to load node editor script */
  21947. editorURL?: string;
  21948. }
  21949. /** @hidden */
  21950. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21951. NORMAL: boolean;
  21952. TANGENT: boolean;
  21953. UV1: boolean;
  21954. /** BONES */
  21955. NUM_BONE_INFLUENCERS: number;
  21956. BonesPerMesh: number;
  21957. BONETEXTURE: boolean;
  21958. /** MORPH TARGETS */
  21959. MORPHTARGETS: boolean;
  21960. MORPHTARGETS_NORMAL: boolean;
  21961. MORPHTARGETS_TANGENT: boolean;
  21962. MORPHTARGETS_UV: boolean;
  21963. NUM_MORPH_INFLUENCERS: number;
  21964. /** IMAGE PROCESSING */
  21965. IMAGEPROCESSING: boolean;
  21966. VIGNETTE: boolean;
  21967. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21968. VIGNETTEBLENDMODEOPAQUE: boolean;
  21969. TONEMAPPING: boolean;
  21970. TONEMAPPING_ACES: boolean;
  21971. CONTRAST: boolean;
  21972. EXPOSURE: boolean;
  21973. COLORCURVES: boolean;
  21974. COLORGRADING: boolean;
  21975. COLORGRADING3D: boolean;
  21976. SAMPLER3DGREENDEPTH: boolean;
  21977. SAMPLER3DBGRMAP: boolean;
  21978. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21979. /** MISC. */
  21980. BUMPDIRECTUV: number;
  21981. constructor();
  21982. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21983. }
  21984. /**
  21985. * Class used to configure NodeMaterial
  21986. */
  21987. export interface INodeMaterialOptions {
  21988. /**
  21989. * Defines if blocks should emit comments
  21990. */
  21991. emitComments: boolean;
  21992. }
  21993. /**
  21994. * Class used to create a node based material built by assembling shader blocks
  21995. */
  21996. export class NodeMaterial extends PushMaterial {
  21997. private static _BuildIdGenerator;
  21998. private _options;
  21999. private _vertexCompilationState;
  22000. private _fragmentCompilationState;
  22001. private _sharedData;
  22002. private _buildId;
  22003. private _buildWasSuccessful;
  22004. private _cachedWorldViewMatrix;
  22005. private _cachedWorldViewProjectionMatrix;
  22006. private _optimizers;
  22007. private _animationFrame;
  22008. /** Define the Url to load node editor script */
  22009. static EditorURL: string;
  22010. /** Define the Url to load snippets */
  22011. static SnippetUrl: string;
  22012. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22013. static IgnoreTexturesAtLoadTime: boolean;
  22014. private BJSNODEMATERIALEDITOR;
  22015. /** Get the inspector from bundle or global */
  22016. private _getGlobalNodeMaterialEditor;
  22017. /**
  22018. * Snippet ID if the material was created from the snippet server
  22019. */
  22020. snippetId: string;
  22021. /**
  22022. * Gets or sets data used by visual editor
  22023. * @see https://nme.babylonjs.com
  22024. */
  22025. editorData: any;
  22026. /**
  22027. * 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)
  22028. */
  22029. ignoreAlpha: boolean;
  22030. /**
  22031. * Defines the maximum number of lights that can be used in the material
  22032. */
  22033. maxSimultaneousLights: number;
  22034. /**
  22035. * Observable raised when the material is built
  22036. */
  22037. onBuildObservable: Observable<NodeMaterial>;
  22038. /**
  22039. * Gets or sets the root nodes of the material vertex shader
  22040. */
  22041. _vertexOutputNodes: NodeMaterialBlock[];
  22042. /**
  22043. * Gets or sets the root nodes of the material fragment (pixel) shader
  22044. */
  22045. _fragmentOutputNodes: NodeMaterialBlock[];
  22046. /** Gets or sets options to control the node material overall behavior */
  22047. get options(): INodeMaterialOptions;
  22048. set options(options: INodeMaterialOptions);
  22049. /**
  22050. * Default configuration related to image processing available in the standard Material.
  22051. */
  22052. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22053. /**
  22054. * Gets the image processing configuration used either in this material.
  22055. */
  22056. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22057. /**
  22058. * Sets the Default image processing configuration used either in the this material.
  22059. *
  22060. * If sets to null, the scene one is in use.
  22061. */
  22062. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22063. /**
  22064. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22065. */
  22066. attachedBlocks: NodeMaterialBlock[];
  22067. /**
  22068. * Specifies the mode of the node material
  22069. * @hidden
  22070. */
  22071. _mode: NodeMaterialModes;
  22072. /**
  22073. * Gets the mode property
  22074. */
  22075. get mode(): NodeMaterialModes;
  22076. /**
  22077. * Create a new node based material
  22078. * @param name defines the material name
  22079. * @param scene defines the hosting scene
  22080. * @param options defines creation option
  22081. */
  22082. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22083. /**
  22084. * Gets the current class name of the material e.g. "NodeMaterial"
  22085. * @returns the class name
  22086. */
  22087. getClassName(): string;
  22088. /**
  22089. * Keep track of the image processing observer to allow dispose and replace.
  22090. */
  22091. private _imageProcessingObserver;
  22092. /**
  22093. * Attaches a new image processing configuration to the Standard Material.
  22094. * @param configuration
  22095. */
  22096. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22097. /**
  22098. * Get a block by its name
  22099. * @param name defines the name of the block to retrieve
  22100. * @returns the required block or null if not found
  22101. */
  22102. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22103. /**
  22104. * Get a block by its name
  22105. * @param predicate defines the predicate used to find the good candidate
  22106. * @returns the required block or null if not found
  22107. */
  22108. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22109. /**
  22110. * Get an input block by its name
  22111. * @param predicate defines the predicate used to find the good candidate
  22112. * @returns the required input block or null if not found
  22113. */
  22114. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22115. /**
  22116. * Gets the list of input blocks attached to this material
  22117. * @returns an array of InputBlocks
  22118. */
  22119. getInputBlocks(): InputBlock[];
  22120. /**
  22121. * Adds a new optimizer to the list of optimizers
  22122. * @param optimizer defines the optimizers to add
  22123. * @returns the current material
  22124. */
  22125. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22126. /**
  22127. * Remove an optimizer from the list of optimizers
  22128. * @param optimizer defines the optimizers to remove
  22129. * @returns the current material
  22130. */
  22131. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22132. /**
  22133. * Add a new block to the list of output nodes
  22134. * @param node defines the node to add
  22135. * @returns the current material
  22136. */
  22137. addOutputNode(node: NodeMaterialBlock): this;
  22138. /**
  22139. * Remove a block from the list of root nodes
  22140. * @param node defines the node to remove
  22141. * @returns the current material
  22142. */
  22143. removeOutputNode(node: NodeMaterialBlock): this;
  22144. private _addVertexOutputNode;
  22145. private _removeVertexOutputNode;
  22146. private _addFragmentOutputNode;
  22147. private _removeFragmentOutputNode;
  22148. /**
  22149. * Specifies if the material will require alpha blending
  22150. * @returns a boolean specifying if alpha blending is needed
  22151. */
  22152. needAlphaBlending(): boolean;
  22153. /**
  22154. * Specifies if this material should be rendered in alpha test mode
  22155. * @returns a boolean specifying if an alpha test is needed.
  22156. */
  22157. needAlphaTesting(): boolean;
  22158. private _initializeBlock;
  22159. private _resetDualBlocks;
  22160. /**
  22161. * Remove a block from the current node material
  22162. * @param block defines the block to remove
  22163. */
  22164. removeBlock(block: NodeMaterialBlock): void;
  22165. /**
  22166. * Build the material and generates the inner effect
  22167. * @param verbose defines if the build should log activity
  22168. */
  22169. build(verbose?: boolean): void;
  22170. /**
  22171. * Runs an otpimization phase to try to improve the shader code
  22172. */
  22173. optimize(): void;
  22174. private _prepareDefinesForAttributes;
  22175. /**
  22176. * Create a post process from the material
  22177. * @param camera The camera to apply the render pass to.
  22178. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22179. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22180. * @param engine The engine which the post process will be applied. (default: current engine)
  22181. * @param reusable If the post process can be reused on the same frame. (default: false)
  22182. * @param textureType Type of textures used when performing the post process. (default: 0)
  22183. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22184. * @returns the post process created
  22185. */
  22186. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22187. /**
  22188. * Create the post process effect from the material
  22189. * @param postProcess The post process to create the effect for
  22190. */
  22191. createEffectForPostProcess(postProcess: PostProcess): void;
  22192. private _createEffectOrPostProcess;
  22193. private _createEffectForParticles;
  22194. /**
  22195. * Create the effect to be used as the custom effect for a particle system
  22196. * @param particleSystem Particle system to create the effect for
  22197. * @param onCompiled defines a function to call when the effect creation is successful
  22198. * @param onError defines a function to call when the effect creation has failed
  22199. */
  22200. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22201. private _processDefines;
  22202. /**
  22203. * Get if the submesh is ready to be used and all its information available.
  22204. * Child classes can use it to update shaders
  22205. * @param mesh defines the mesh to check
  22206. * @param subMesh defines which submesh to check
  22207. * @param useInstances specifies that instances should be used
  22208. * @returns a boolean indicating that the submesh is ready or not
  22209. */
  22210. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22211. /**
  22212. * Get a string representing the shaders built by the current node graph
  22213. */
  22214. get compiledShaders(): string;
  22215. /**
  22216. * Binds the world matrix to the material
  22217. * @param world defines the world transformation matrix
  22218. */
  22219. bindOnlyWorldMatrix(world: Matrix): void;
  22220. /**
  22221. * Binds the submesh to this material by preparing the effect and shader to draw
  22222. * @param world defines the world transformation matrix
  22223. * @param mesh defines the mesh containing the submesh
  22224. * @param subMesh defines the submesh to bind the material to
  22225. */
  22226. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22227. /**
  22228. * Gets the active textures from the material
  22229. * @returns an array of textures
  22230. */
  22231. getActiveTextures(): BaseTexture[];
  22232. /**
  22233. * Gets the list of texture blocks
  22234. * @returns an array of texture blocks
  22235. */
  22236. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22237. /**
  22238. * Specifies if the material uses a texture
  22239. * @param texture defines the texture to check against the material
  22240. * @returns a boolean specifying if the material uses the texture
  22241. */
  22242. hasTexture(texture: BaseTexture): boolean;
  22243. /**
  22244. * Disposes the material
  22245. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22246. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22247. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22248. */
  22249. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22250. /** Creates the node editor window. */
  22251. private _createNodeEditor;
  22252. /**
  22253. * Launch the node material editor
  22254. * @param config Define the configuration of the editor
  22255. * @return a promise fulfilled when the node editor is visible
  22256. */
  22257. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22258. /**
  22259. * Clear the current material
  22260. */
  22261. clear(): void;
  22262. /**
  22263. * Clear the current material and set it to a default state
  22264. */
  22265. setToDefault(): void;
  22266. /**
  22267. * Clear the current material and set it to a default state for post process
  22268. */
  22269. setToDefaultPostProcess(): void;
  22270. /**
  22271. * Clear the current material and set it to a default state for particle
  22272. */
  22273. setToDefaultParticle(): void;
  22274. /**
  22275. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22276. * @param url defines the url to load from
  22277. * @returns a promise that will fullfil when the material is fully loaded
  22278. */
  22279. loadAsync(url: string): Promise<void>;
  22280. private _gatherBlocks;
  22281. /**
  22282. * Generate a string containing the code declaration required to create an equivalent of this material
  22283. * @returns a string
  22284. */
  22285. generateCode(): string;
  22286. /**
  22287. * Serializes this material in a JSON representation
  22288. * @returns the serialized material object
  22289. */
  22290. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22291. private _restoreConnections;
  22292. /**
  22293. * Clear the current graph and load a new one from a serialization object
  22294. * @param source defines the JSON representation of the material
  22295. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22296. */
  22297. loadFromSerialization(source: any, rootUrl?: string): void;
  22298. /**
  22299. * Makes a duplicate of the current material.
  22300. * @param name - name to use for the new material.
  22301. */
  22302. clone(name: string): NodeMaterial;
  22303. /**
  22304. * Creates a node material from parsed material data
  22305. * @param source defines the JSON representation of the material
  22306. * @param scene defines the hosting scene
  22307. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22308. * @returns a new node material
  22309. */
  22310. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22311. /**
  22312. * Creates a node material from a snippet saved in a remote file
  22313. * @param name defines the name of the material to create
  22314. * @param url defines the url to load from
  22315. * @param scene defines the hosting scene
  22316. * @returns a promise that will resolve to the new node material
  22317. */
  22318. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22319. /**
  22320. * Creates a node material from a snippet saved by the node material editor
  22321. * @param snippetId defines the snippet to load
  22322. * @param scene defines the hosting scene
  22323. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22324. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22325. * @returns a promise that will resolve to the new node material
  22326. */
  22327. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22328. /**
  22329. * Creates a new node material set to default basic configuration
  22330. * @param name defines the name of the material
  22331. * @param scene defines the hosting scene
  22332. * @returns a new NodeMaterial
  22333. */
  22334. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22335. }
  22336. }
  22337. declare module BABYLON {
  22338. /**
  22339. * Size options for a post process
  22340. */
  22341. export type PostProcessOptions = {
  22342. width: number;
  22343. height: number;
  22344. };
  22345. /**
  22346. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22347. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22348. */
  22349. export class PostProcess {
  22350. /** Name of the PostProcess. */
  22351. name: string;
  22352. /**
  22353. * Gets or sets the unique id of the post process
  22354. */
  22355. uniqueId: number;
  22356. /**
  22357. * Width of the texture to apply the post process on
  22358. */
  22359. width: number;
  22360. /**
  22361. * Height of the texture to apply the post process on
  22362. */
  22363. height: number;
  22364. /**
  22365. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22366. */
  22367. nodeMaterialSource: Nullable<NodeMaterial>;
  22368. /**
  22369. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22370. * @hidden
  22371. */
  22372. _outputTexture: Nullable<InternalTexture>;
  22373. /**
  22374. * Sampling mode used by the shader
  22375. * See https://doc.babylonjs.com/classes/3.1/texture
  22376. */
  22377. renderTargetSamplingMode: number;
  22378. /**
  22379. * Clear color to use when screen clearing
  22380. */
  22381. clearColor: Color4;
  22382. /**
  22383. * If the buffer needs to be cleared before applying the post process. (default: true)
  22384. * Should be set to false if shader will overwrite all previous pixels.
  22385. */
  22386. autoClear: boolean;
  22387. /**
  22388. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22389. */
  22390. alphaMode: number;
  22391. /**
  22392. * Sets the setAlphaBlendConstants of the babylon engine
  22393. */
  22394. alphaConstants: Color4;
  22395. /**
  22396. * Animations to be used for the post processing
  22397. */
  22398. animations: Animation[];
  22399. /**
  22400. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22401. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22402. */
  22403. enablePixelPerfectMode: boolean;
  22404. /**
  22405. * Force the postprocess to be applied without taking in account viewport
  22406. */
  22407. forceFullscreenViewport: boolean;
  22408. /**
  22409. * List of inspectable custom properties (used by the Inspector)
  22410. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22411. */
  22412. inspectableCustomProperties: IInspectable[];
  22413. /**
  22414. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22415. *
  22416. * | Value | Type | Description |
  22417. * | ----- | ----------------------------------- | ----------- |
  22418. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22419. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22420. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22421. *
  22422. */
  22423. scaleMode: number;
  22424. /**
  22425. * Force textures to be a power of two (default: false)
  22426. */
  22427. alwaysForcePOT: boolean;
  22428. private _samples;
  22429. /**
  22430. * Number of sample textures (default: 1)
  22431. */
  22432. get samples(): number;
  22433. set samples(n: number);
  22434. /**
  22435. * Modify the scale of the post process to be the same as the viewport (default: false)
  22436. */
  22437. adaptScaleToCurrentViewport: boolean;
  22438. private _camera;
  22439. private _scene;
  22440. private _engine;
  22441. private _options;
  22442. private _reusable;
  22443. private _textureType;
  22444. private _textureFormat;
  22445. /**
  22446. * Smart array of input and output textures for the post process.
  22447. * @hidden
  22448. */
  22449. _textures: SmartArray<InternalTexture>;
  22450. /**
  22451. * The index in _textures that corresponds to the output texture.
  22452. * @hidden
  22453. */
  22454. _currentRenderTextureInd: number;
  22455. private _effect;
  22456. private _samplers;
  22457. private _fragmentUrl;
  22458. private _vertexUrl;
  22459. private _parameters;
  22460. private _scaleRatio;
  22461. protected _indexParameters: any;
  22462. private _shareOutputWithPostProcess;
  22463. private _texelSize;
  22464. private _forcedOutputTexture;
  22465. /**
  22466. * Returns the fragment url or shader name used in the post process.
  22467. * @returns the fragment url or name in the shader store.
  22468. */
  22469. getEffectName(): string;
  22470. /**
  22471. * An event triggered when the postprocess is activated.
  22472. */
  22473. onActivateObservable: Observable<Camera>;
  22474. private _onActivateObserver;
  22475. /**
  22476. * A function that is added to the onActivateObservable
  22477. */
  22478. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22479. /**
  22480. * An event triggered when the postprocess changes its size.
  22481. */
  22482. onSizeChangedObservable: Observable<PostProcess>;
  22483. private _onSizeChangedObserver;
  22484. /**
  22485. * A function that is added to the onSizeChangedObservable
  22486. */
  22487. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22488. /**
  22489. * An event triggered when the postprocess applies its effect.
  22490. */
  22491. onApplyObservable: Observable<Effect>;
  22492. private _onApplyObserver;
  22493. /**
  22494. * A function that is added to the onApplyObservable
  22495. */
  22496. set onApply(callback: (effect: Effect) => void);
  22497. /**
  22498. * An event triggered before rendering the postprocess
  22499. */
  22500. onBeforeRenderObservable: Observable<Effect>;
  22501. private _onBeforeRenderObserver;
  22502. /**
  22503. * A function that is added to the onBeforeRenderObservable
  22504. */
  22505. set onBeforeRender(callback: (effect: Effect) => void);
  22506. /**
  22507. * An event triggered after rendering the postprocess
  22508. */
  22509. onAfterRenderObservable: Observable<Effect>;
  22510. private _onAfterRenderObserver;
  22511. /**
  22512. * A function that is added to the onAfterRenderObservable
  22513. */
  22514. set onAfterRender(callback: (efect: Effect) => void);
  22515. /**
  22516. * 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
  22517. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22518. */
  22519. get inputTexture(): InternalTexture;
  22520. set inputTexture(value: InternalTexture);
  22521. /**
  22522. * Gets the camera which post process is applied to.
  22523. * @returns The camera the post process is applied to.
  22524. */
  22525. getCamera(): Camera;
  22526. /**
  22527. * Gets the texel size of the postprocess.
  22528. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22529. */
  22530. get texelSize(): Vector2;
  22531. /**
  22532. * Creates a new instance PostProcess
  22533. * @param name The name of the PostProcess.
  22534. * @param fragmentUrl The url of the fragment shader to be used.
  22535. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22536. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22537. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22538. * @param camera The camera to apply the render pass to.
  22539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22540. * @param engine The engine which the post process will be applied. (default: current engine)
  22541. * @param reusable If the post process can be reused on the same frame. (default: false)
  22542. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22543. * @param textureType Type of textures used when performing the post process. (default: 0)
  22544. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22545. * @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
  22546. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22547. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22548. */
  22549. constructor(
  22550. /** Name of the PostProcess. */
  22551. 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);
  22552. /**
  22553. * Gets a string idenfifying the name of the class
  22554. * @returns "PostProcess" string
  22555. */
  22556. getClassName(): string;
  22557. /**
  22558. * Gets the engine which this post process belongs to.
  22559. * @returns The engine the post process was enabled with.
  22560. */
  22561. getEngine(): Engine;
  22562. /**
  22563. * The effect that is created when initializing the post process.
  22564. * @returns The created effect corresponding the the postprocess.
  22565. */
  22566. getEffect(): Effect;
  22567. /**
  22568. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22569. * @param postProcess The post process to share the output with.
  22570. * @returns This post process.
  22571. */
  22572. shareOutputWith(postProcess: PostProcess): PostProcess;
  22573. /**
  22574. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22575. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22576. */
  22577. useOwnOutput(): void;
  22578. /**
  22579. * Updates the effect with the current post process compile time values and recompiles the shader.
  22580. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22581. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22582. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22583. * @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
  22584. * @param onCompiled Called when the shader has been compiled.
  22585. * @param onError Called if there is an error when compiling a shader.
  22586. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22587. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22588. */
  22589. 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;
  22590. /**
  22591. * The post process is reusable if it can be used multiple times within one frame.
  22592. * @returns If the post process is reusable
  22593. */
  22594. isReusable(): boolean;
  22595. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22596. markTextureDirty(): void;
  22597. /**
  22598. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22599. * 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.
  22600. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22601. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22602. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22603. * @returns The target texture that was bound to be written to.
  22604. */
  22605. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22606. /**
  22607. * If the post process is supported.
  22608. */
  22609. get isSupported(): boolean;
  22610. /**
  22611. * The aspect ratio of the output texture.
  22612. */
  22613. get aspectRatio(): number;
  22614. /**
  22615. * Get a value indicating if the post-process is ready to be used
  22616. * @returns true if the post-process is ready (shader is compiled)
  22617. */
  22618. isReady(): boolean;
  22619. /**
  22620. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22621. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22622. */
  22623. apply(): Nullable<Effect>;
  22624. private _disposeTextures;
  22625. /**
  22626. * Disposes the post process.
  22627. * @param camera The camera to dispose the post process on.
  22628. */
  22629. dispose(camera?: Camera): void;
  22630. }
  22631. }
  22632. declare module BABYLON {
  22633. /** @hidden */
  22634. export var kernelBlurVaryingDeclaration: {
  22635. name: string;
  22636. shader: string;
  22637. };
  22638. }
  22639. declare module BABYLON {
  22640. /** @hidden */
  22641. export var kernelBlurFragment: {
  22642. name: string;
  22643. shader: string;
  22644. };
  22645. }
  22646. declare module BABYLON {
  22647. /** @hidden */
  22648. export var kernelBlurFragment2: {
  22649. name: string;
  22650. shader: string;
  22651. };
  22652. }
  22653. declare module BABYLON {
  22654. /** @hidden */
  22655. export var kernelBlurPixelShader: {
  22656. name: string;
  22657. shader: string;
  22658. };
  22659. }
  22660. declare module BABYLON {
  22661. /** @hidden */
  22662. export var kernelBlurVertex: {
  22663. name: string;
  22664. shader: string;
  22665. };
  22666. }
  22667. declare module BABYLON {
  22668. /** @hidden */
  22669. export var kernelBlurVertexShader: {
  22670. name: string;
  22671. shader: string;
  22672. };
  22673. }
  22674. declare module BABYLON {
  22675. /**
  22676. * The Blur Post Process which blurs an image based on a kernel and direction.
  22677. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22678. */
  22679. export class BlurPostProcess extends PostProcess {
  22680. /** The direction in which to blur the image. */
  22681. direction: Vector2;
  22682. private blockCompilation;
  22683. protected _kernel: number;
  22684. protected _idealKernel: number;
  22685. protected _packedFloat: boolean;
  22686. private _staticDefines;
  22687. /**
  22688. * Sets the length in pixels of the blur sample region
  22689. */
  22690. set kernel(v: number);
  22691. /**
  22692. * Gets the length in pixels of the blur sample region
  22693. */
  22694. get kernel(): number;
  22695. /**
  22696. * Sets wether or not the blur needs to unpack/repack floats
  22697. */
  22698. set packedFloat(v: boolean);
  22699. /**
  22700. * Gets wether or not the blur is unpacking/repacking floats
  22701. */
  22702. get packedFloat(): boolean;
  22703. /**
  22704. * Creates a new instance BlurPostProcess
  22705. * @param name The name of the effect.
  22706. * @param direction The direction in which to blur the image.
  22707. * @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.
  22708. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22709. * @param camera The camera to apply the render pass to.
  22710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22711. * @param engine The engine which the post process will be applied. (default: current engine)
  22712. * @param reusable If the post process can be reused on the same frame. (default: false)
  22713. * @param textureType Type of textures used when performing the post process. (default: 0)
  22714. * @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)
  22715. */
  22716. constructor(name: string,
  22717. /** The direction in which to blur the image. */
  22718. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22719. /**
  22720. * Updates the effect with the current post process compile time values and recompiles the shader.
  22721. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22722. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22723. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22724. * @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
  22725. * @param onCompiled Called when the shader has been compiled.
  22726. * @param onError Called if there is an error when compiling a shader.
  22727. */
  22728. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22729. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22730. /**
  22731. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22732. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22733. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22734. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22735. * The gaps between physical kernels are compensated for in the weighting of the samples
  22736. * @param idealKernel Ideal blur kernel.
  22737. * @return Nearest best kernel.
  22738. */
  22739. protected _nearestBestKernel(idealKernel: number): number;
  22740. /**
  22741. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22742. * @param x The point on the Gaussian distribution to sample.
  22743. * @return the value of the Gaussian function at x.
  22744. */
  22745. protected _gaussianWeight(x: number): number;
  22746. /**
  22747. * Generates a string that can be used as a floating point number in GLSL.
  22748. * @param x Value to print.
  22749. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22750. * @return GLSL float string.
  22751. */
  22752. protected _glslFloat(x: number, decimalFigures?: number): string;
  22753. }
  22754. }
  22755. declare module BABYLON {
  22756. /**
  22757. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22758. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22759. * You can then easily use it as a reflectionTexture on a flat surface.
  22760. * In case the surface is not a plane, please consider relying on reflection probes.
  22761. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22762. */
  22763. export class MirrorTexture extends RenderTargetTexture {
  22764. private scene;
  22765. /**
  22766. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22767. * 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.
  22768. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22769. */
  22770. mirrorPlane: Plane;
  22771. /**
  22772. * Define the blur ratio used to blur the reflection if needed.
  22773. */
  22774. set blurRatio(value: number);
  22775. get blurRatio(): number;
  22776. /**
  22777. * Define the adaptive blur kernel used to blur the reflection if needed.
  22778. * This will autocompute the closest best match for the `blurKernel`
  22779. */
  22780. set adaptiveBlurKernel(value: number);
  22781. /**
  22782. * Define the blur kernel used to blur the reflection if needed.
  22783. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22784. */
  22785. set blurKernel(value: number);
  22786. /**
  22787. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22788. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22789. */
  22790. set blurKernelX(value: number);
  22791. get blurKernelX(): number;
  22792. /**
  22793. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22794. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22795. */
  22796. set blurKernelY(value: number);
  22797. get blurKernelY(): number;
  22798. private _autoComputeBlurKernel;
  22799. protected _onRatioRescale(): void;
  22800. private _updateGammaSpace;
  22801. private _imageProcessingConfigChangeObserver;
  22802. private _transformMatrix;
  22803. private _mirrorMatrix;
  22804. private _savedViewMatrix;
  22805. private _blurX;
  22806. private _blurY;
  22807. private _adaptiveBlurKernel;
  22808. private _blurKernelX;
  22809. private _blurKernelY;
  22810. private _blurRatio;
  22811. /**
  22812. * Instantiates a Mirror Texture.
  22813. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22814. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22815. * You can then easily use it as a reflectionTexture on a flat surface.
  22816. * In case the surface is not a plane, please consider relying on reflection probes.
  22817. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22818. * @param name
  22819. * @param size
  22820. * @param scene
  22821. * @param generateMipMaps
  22822. * @param type
  22823. * @param samplingMode
  22824. * @param generateDepthBuffer
  22825. */
  22826. constructor(name: string, size: number | {
  22827. width: number;
  22828. height: number;
  22829. } | {
  22830. ratio: number;
  22831. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22832. private _preparePostProcesses;
  22833. /**
  22834. * Clone the mirror texture.
  22835. * @returns the cloned texture
  22836. */
  22837. clone(): MirrorTexture;
  22838. /**
  22839. * Serialize the texture to a JSON representation you could use in Parse later on
  22840. * @returns the serialized JSON representation
  22841. */
  22842. serialize(): any;
  22843. /**
  22844. * Dispose the texture and release its associated resources.
  22845. */
  22846. dispose(): void;
  22847. }
  22848. }
  22849. declare module BABYLON {
  22850. /**
  22851. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22852. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22853. */
  22854. export class Texture extends BaseTexture {
  22855. /**
  22856. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22857. */
  22858. static SerializeBuffers: boolean;
  22859. /** @hidden */
  22860. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22861. /** @hidden */
  22862. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22863. /** @hidden */
  22864. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22865. /** nearest is mag = nearest and min = nearest and mip = linear */
  22866. static readonly NEAREST_SAMPLINGMODE: number;
  22867. /** nearest is mag = nearest and min = nearest and mip = linear */
  22868. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22869. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22870. static readonly BILINEAR_SAMPLINGMODE: number;
  22871. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22872. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22873. /** Trilinear is mag = linear and min = linear and mip = linear */
  22874. static readonly TRILINEAR_SAMPLINGMODE: number;
  22875. /** Trilinear is mag = linear and min = linear and mip = linear */
  22876. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22877. /** mag = nearest and min = nearest and mip = nearest */
  22878. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22879. /** mag = nearest and min = linear and mip = nearest */
  22880. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22881. /** mag = nearest and min = linear and mip = linear */
  22882. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22883. /** mag = nearest and min = linear and mip = none */
  22884. static readonly NEAREST_LINEAR: number;
  22885. /** mag = nearest and min = nearest and mip = none */
  22886. static readonly NEAREST_NEAREST: number;
  22887. /** mag = linear and min = nearest and mip = nearest */
  22888. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22889. /** mag = linear and min = nearest and mip = linear */
  22890. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22891. /** mag = linear and min = linear and mip = none */
  22892. static readonly LINEAR_LINEAR: number;
  22893. /** mag = linear and min = nearest and mip = none */
  22894. static readonly LINEAR_NEAREST: number;
  22895. /** Explicit coordinates mode */
  22896. static readonly EXPLICIT_MODE: number;
  22897. /** Spherical coordinates mode */
  22898. static readonly SPHERICAL_MODE: number;
  22899. /** Planar coordinates mode */
  22900. static readonly PLANAR_MODE: number;
  22901. /** Cubic coordinates mode */
  22902. static readonly CUBIC_MODE: number;
  22903. /** Projection coordinates mode */
  22904. static readonly PROJECTION_MODE: number;
  22905. /** Inverse Cubic coordinates mode */
  22906. static readonly SKYBOX_MODE: number;
  22907. /** Inverse Cubic coordinates mode */
  22908. static readonly INVCUBIC_MODE: number;
  22909. /** Equirectangular coordinates mode */
  22910. static readonly EQUIRECTANGULAR_MODE: number;
  22911. /** Equirectangular Fixed coordinates mode */
  22912. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22913. /** Equirectangular Fixed Mirrored coordinates mode */
  22914. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22915. /** Texture is not repeating outside of 0..1 UVs */
  22916. static readonly CLAMP_ADDRESSMODE: number;
  22917. /** Texture is repeating outside of 0..1 UVs */
  22918. static readonly WRAP_ADDRESSMODE: number;
  22919. /** Texture is repeating and mirrored */
  22920. static readonly MIRROR_ADDRESSMODE: number;
  22921. /**
  22922. * 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
  22923. */
  22924. static UseSerializedUrlIfAny: boolean;
  22925. /**
  22926. * Define the url of the texture.
  22927. */
  22928. url: Nullable<string>;
  22929. /**
  22930. * Define an offset on the texture to offset the u coordinates of the UVs
  22931. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22932. */
  22933. uOffset: number;
  22934. /**
  22935. * Define an offset on the texture to offset the v coordinates of the UVs
  22936. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22937. */
  22938. vOffset: number;
  22939. /**
  22940. * Define an offset on the texture to scale the u coordinates of the UVs
  22941. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22942. */
  22943. uScale: number;
  22944. /**
  22945. * Define an offset on the texture to scale the v coordinates of the UVs
  22946. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22947. */
  22948. vScale: number;
  22949. /**
  22950. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22951. * @see http://doc.babylonjs.com/how_to/more_materials
  22952. */
  22953. uAng: number;
  22954. /**
  22955. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22956. * @see http://doc.babylonjs.com/how_to/more_materials
  22957. */
  22958. vAng: number;
  22959. /**
  22960. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22961. * @see http://doc.babylonjs.com/how_to/more_materials
  22962. */
  22963. wAng: number;
  22964. /**
  22965. * Defines the center of rotation (U)
  22966. */
  22967. uRotationCenter: number;
  22968. /**
  22969. * Defines the center of rotation (V)
  22970. */
  22971. vRotationCenter: number;
  22972. /**
  22973. * Defines the center of rotation (W)
  22974. */
  22975. wRotationCenter: number;
  22976. /**
  22977. * Are mip maps generated for this texture or not.
  22978. */
  22979. get noMipmap(): boolean;
  22980. /**
  22981. * List of inspectable custom properties (used by the Inspector)
  22982. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22983. */
  22984. inspectableCustomProperties: Nullable<IInspectable[]>;
  22985. private _noMipmap;
  22986. /** @hidden */
  22987. _invertY: boolean;
  22988. private _rowGenerationMatrix;
  22989. private _cachedTextureMatrix;
  22990. private _projectionModeMatrix;
  22991. private _t0;
  22992. private _t1;
  22993. private _t2;
  22994. private _cachedUOffset;
  22995. private _cachedVOffset;
  22996. private _cachedUScale;
  22997. private _cachedVScale;
  22998. private _cachedUAng;
  22999. private _cachedVAng;
  23000. private _cachedWAng;
  23001. private _cachedProjectionMatrixId;
  23002. private _cachedCoordinatesMode;
  23003. /** @hidden */
  23004. protected _initialSamplingMode: number;
  23005. /** @hidden */
  23006. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23007. private _deleteBuffer;
  23008. protected _format: Nullable<number>;
  23009. private _delayedOnLoad;
  23010. private _delayedOnError;
  23011. private _mimeType?;
  23012. /**
  23013. * Observable triggered once the texture has been loaded.
  23014. */
  23015. onLoadObservable: Observable<Texture>;
  23016. protected _isBlocking: boolean;
  23017. /**
  23018. * Is the texture preventing material to render while loading.
  23019. * If false, a default texture will be used instead of the loading one during the preparation step.
  23020. */
  23021. set isBlocking(value: boolean);
  23022. get isBlocking(): boolean;
  23023. /**
  23024. * Get the current sampling mode associated with the texture.
  23025. */
  23026. get samplingMode(): number;
  23027. /**
  23028. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23029. */
  23030. get invertY(): boolean;
  23031. /**
  23032. * Instantiates a new texture.
  23033. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23034. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23035. * @param url defines the url of the picture to load as a texture
  23036. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23037. * @param noMipmap defines if the texture will require mip maps or not
  23038. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23039. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23040. * @param onLoad defines a callback triggered when the texture has been loaded
  23041. * @param onError defines a callback triggered when an error occurred during the loading session
  23042. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23043. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23044. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23045. * @param mimeType defines an optional mime type information
  23046. */
  23047. 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);
  23048. /**
  23049. * Update the url (and optional buffer) of this texture if url was null during construction.
  23050. * @param url the url of the texture
  23051. * @param buffer the buffer of the texture (defaults to null)
  23052. * @param onLoad callback called when the texture is loaded (defaults to null)
  23053. */
  23054. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23055. /**
  23056. * Finish the loading sequence of a texture flagged as delayed load.
  23057. * @hidden
  23058. */
  23059. delayLoad(): void;
  23060. private _prepareRowForTextureGeneration;
  23061. /**
  23062. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23063. * @returns the transform matrix of the texture.
  23064. */
  23065. getTextureMatrix(uBase?: number): Matrix;
  23066. /**
  23067. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23068. * @returns The reflection texture transform
  23069. */
  23070. getReflectionTextureMatrix(): Matrix;
  23071. /**
  23072. * Clones the texture.
  23073. * @returns the cloned texture
  23074. */
  23075. clone(): Texture;
  23076. /**
  23077. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23078. * @returns The JSON representation of the texture
  23079. */
  23080. serialize(): any;
  23081. /**
  23082. * Get the current class name of the texture useful for serialization or dynamic coding.
  23083. * @returns "Texture"
  23084. */
  23085. getClassName(): string;
  23086. /**
  23087. * Dispose the texture and release its associated resources.
  23088. */
  23089. dispose(): void;
  23090. /**
  23091. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23092. * @param parsedTexture Define the JSON representation of the texture
  23093. * @param scene Define the scene the parsed texture should be instantiated in
  23094. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23095. * @returns The parsed texture if successful
  23096. */
  23097. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23098. /**
  23099. * Creates a texture from its base 64 representation.
  23100. * @param data Define the base64 payload without the data: prefix
  23101. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23102. * @param scene Define the scene the texture should belong to
  23103. * @param noMipmap Forces the texture to not create mip map information if true
  23104. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23105. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23106. * @param onLoad define a callback triggered when the texture has been loaded
  23107. * @param onError define a callback triggered when an error occurred during the loading session
  23108. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23109. * @returns the created texture
  23110. */
  23111. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23112. /**
  23113. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23114. * @param data Define the base64 payload without the data: prefix
  23115. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23116. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23117. * @param scene Define the scene the texture should belong to
  23118. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23119. * @param noMipmap Forces the texture to not create mip map information if true
  23120. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23121. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23122. * @param onLoad define a callback triggered when the texture has been loaded
  23123. * @param onError define a callback triggered when an error occurred during the loading session
  23124. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23125. * @returns the created texture
  23126. */
  23127. 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;
  23128. }
  23129. }
  23130. declare module BABYLON {
  23131. /**
  23132. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23133. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23134. */
  23135. export class PostProcessManager {
  23136. private _scene;
  23137. private _indexBuffer;
  23138. private _vertexBuffers;
  23139. /**
  23140. * Creates a new instance PostProcess
  23141. * @param scene The scene that the post process is associated with.
  23142. */
  23143. constructor(scene: Scene);
  23144. private _prepareBuffers;
  23145. private _buildIndexBuffer;
  23146. /**
  23147. * Rebuilds the vertex buffers of the manager.
  23148. * @hidden
  23149. */
  23150. _rebuild(): void;
  23151. /**
  23152. * Prepares a frame to be run through a post process.
  23153. * @param sourceTexture The input texture to the post procesess. (default: null)
  23154. * @param postProcesses An array of post processes to be run. (default: null)
  23155. * @returns True if the post processes were able to be run.
  23156. * @hidden
  23157. */
  23158. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23159. /**
  23160. * Manually render a set of post processes to a texture.
  23161. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23162. * @param postProcesses An array of post processes to be run.
  23163. * @param targetTexture The target texture to render to.
  23164. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23165. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23166. * @param lodLevel defines which lod of the texture to render to
  23167. */
  23168. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23169. /**
  23170. * Finalize the result of the output of the postprocesses.
  23171. * @param doNotPresent If true the result will not be displayed to the screen.
  23172. * @param targetTexture The target texture to render to.
  23173. * @param faceIndex The index of the face to bind the target texture to.
  23174. * @param postProcesses The array of post processes to render.
  23175. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23176. * @hidden
  23177. */
  23178. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23179. /**
  23180. * Disposes of the post process manager.
  23181. */
  23182. dispose(): void;
  23183. }
  23184. }
  23185. declare module BABYLON {
  23186. /**
  23187. * This Helps creating a texture that will be created from a camera in your scene.
  23188. * It is basically a dynamic texture that could be used to create special effects for instance.
  23189. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23190. */
  23191. export class RenderTargetTexture extends Texture {
  23192. isCube: boolean;
  23193. /**
  23194. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23195. */
  23196. static readonly REFRESHRATE_RENDER_ONCE: number;
  23197. /**
  23198. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23199. */
  23200. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23201. /**
  23202. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23203. * the central point of your effect and can save a lot of performances.
  23204. */
  23205. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23206. /**
  23207. * Use this predicate to dynamically define the list of mesh you want to render.
  23208. * If set, the renderList property will be overwritten.
  23209. */
  23210. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23211. private _renderList;
  23212. /**
  23213. * Use this list to define the list of mesh you want to render.
  23214. */
  23215. get renderList(): Nullable<Array<AbstractMesh>>;
  23216. set renderList(value: Nullable<Array<AbstractMesh>>);
  23217. /**
  23218. * Use this function to overload the renderList array at rendering time.
  23219. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23220. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23221. * the cube (if the RTT is a cube, else layerOrFace=0).
  23222. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23223. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23224. * hold dummy elements!
  23225. */
  23226. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23227. private _hookArray;
  23228. /**
  23229. * Define if particles should be rendered in your texture.
  23230. */
  23231. renderParticles: boolean;
  23232. /**
  23233. * Define if sprites should be rendered in your texture.
  23234. */
  23235. renderSprites: boolean;
  23236. /**
  23237. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23238. */
  23239. coordinatesMode: number;
  23240. /**
  23241. * Define the camera used to render the texture.
  23242. */
  23243. activeCamera: Nullable<Camera>;
  23244. /**
  23245. * Override the mesh isReady function with your own one.
  23246. */
  23247. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23248. /**
  23249. * Override the render function of the texture with your own one.
  23250. */
  23251. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23252. /**
  23253. * Define if camera post processes should be use while rendering the texture.
  23254. */
  23255. useCameraPostProcesses: boolean;
  23256. /**
  23257. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23258. */
  23259. ignoreCameraViewport: boolean;
  23260. private _postProcessManager;
  23261. private _postProcesses;
  23262. private _resizeObserver;
  23263. /**
  23264. * An event triggered when the texture is unbind.
  23265. */
  23266. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23267. /**
  23268. * An event triggered when the texture is unbind.
  23269. */
  23270. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23271. private _onAfterUnbindObserver;
  23272. /**
  23273. * Set a after unbind callback in the texture.
  23274. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23275. */
  23276. set onAfterUnbind(callback: () => void);
  23277. /**
  23278. * An event triggered before rendering the texture
  23279. */
  23280. onBeforeRenderObservable: Observable<number>;
  23281. private _onBeforeRenderObserver;
  23282. /**
  23283. * Set a before render callback in the texture.
  23284. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23285. */
  23286. set onBeforeRender(callback: (faceIndex: number) => void);
  23287. /**
  23288. * An event triggered after rendering the texture
  23289. */
  23290. onAfterRenderObservable: Observable<number>;
  23291. private _onAfterRenderObserver;
  23292. /**
  23293. * Set a after render callback in the texture.
  23294. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23295. */
  23296. set onAfterRender(callback: (faceIndex: number) => void);
  23297. /**
  23298. * An event triggered after the texture clear
  23299. */
  23300. onClearObservable: Observable<Engine>;
  23301. private _onClearObserver;
  23302. /**
  23303. * Set a clear callback in the texture.
  23304. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23305. */
  23306. set onClear(callback: (Engine: Engine) => void);
  23307. /**
  23308. * An event triggered when the texture is resized.
  23309. */
  23310. onResizeObservable: Observable<RenderTargetTexture>;
  23311. /**
  23312. * Define the clear color of the Render Target if it should be different from the scene.
  23313. */
  23314. clearColor: Color4;
  23315. protected _size: number | {
  23316. width: number;
  23317. height: number;
  23318. layers?: number;
  23319. };
  23320. protected _initialSizeParameter: number | {
  23321. width: number;
  23322. height: number;
  23323. } | {
  23324. ratio: number;
  23325. };
  23326. protected _sizeRatio: Nullable<number>;
  23327. /** @hidden */
  23328. _generateMipMaps: boolean;
  23329. protected _renderingManager: RenderingManager;
  23330. /** @hidden */
  23331. _waitingRenderList: string[];
  23332. protected _doNotChangeAspectRatio: boolean;
  23333. protected _currentRefreshId: number;
  23334. protected _refreshRate: number;
  23335. protected _textureMatrix: Matrix;
  23336. protected _samples: number;
  23337. protected _renderTargetOptions: RenderTargetCreationOptions;
  23338. /**
  23339. * Gets render target creation options that were used.
  23340. */
  23341. get renderTargetOptions(): RenderTargetCreationOptions;
  23342. protected _onRatioRescale(): void;
  23343. /**
  23344. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23345. * It must define where the camera used to render the texture is set
  23346. */
  23347. boundingBoxPosition: Vector3;
  23348. private _boundingBoxSize;
  23349. /**
  23350. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23351. * When defined, the cubemap will switch to local mode
  23352. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23353. * @example https://www.babylonjs-playground.com/#RNASML
  23354. */
  23355. set boundingBoxSize(value: Vector3);
  23356. get boundingBoxSize(): Vector3;
  23357. /**
  23358. * In case the RTT has been created with a depth texture, get the associated
  23359. * depth texture.
  23360. * Otherwise, return null.
  23361. */
  23362. get depthStencilTexture(): Nullable<InternalTexture>;
  23363. /**
  23364. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23365. * or used a shadow, depth texture...
  23366. * @param name The friendly name of the texture
  23367. * @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)
  23368. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23369. * @param generateMipMaps True if mip maps need to be generated after render.
  23370. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23371. * @param type The type of the buffer in the RTT (int, half float, float...)
  23372. * @param isCube True if a cube texture needs to be created
  23373. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23374. * @param generateDepthBuffer True to generate a depth buffer
  23375. * @param generateStencilBuffer True to generate a stencil buffer
  23376. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23377. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23378. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23379. */
  23380. constructor(name: string, size: number | {
  23381. width: number;
  23382. height: number;
  23383. layers?: number;
  23384. } | {
  23385. ratio: number;
  23386. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23387. /**
  23388. * Creates a depth stencil texture.
  23389. * This is only available in WebGL 2 or with the depth texture extension available.
  23390. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23391. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23392. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23393. */
  23394. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23395. private _processSizeParameter;
  23396. /**
  23397. * Define the number of samples to use in case of MSAA.
  23398. * It defaults to one meaning no MSAA has been enabled.
  23399. */
  23400. get samples(): number;
  23401. set samples(value: number);
  23402. /**
  23403. * Resets the refresh counter of the texture and start bak from scratch.
  23404. * Could be useful to regenerate the texture if it is setup to render only once.
  23405. */
  23406. resetRefreshCounter(): void;
  23407. /**
  23408. * Define the refresh rate of the texture or the rendering frequency.
  23409. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23410. */
  23411. get refreshRate(): number;
  23412. set refreshRate(value: number);
  23413. /**
  23414. * Adds a post process to the render target rendering passes.
  23415. * @param postProcess define the post process to add
  23416. */
  23417. addPostProcess(postProcess: PostProcess): void;
  23418. /**
  23419. * Clear all the post processes attached to the render target
  23420. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23421. */
  23422. clearPostProcesses(dispose?: boolean): void;
  23423. /**
  23424. * Remove one of the post process from the list of attached post processes to the texture
  23425. * @param postProcess define the post process to remove from the list
  23426. */
  23427. removePostProcess(postProcess: PostProcess): void;
  23428. /** @hidden */
  23429. _shouldRender(): boolean;
  23430. /**
  23431. * Gets the actual render size of the texture.
  23432. * @returns the width of the render size
  23433. */
  23434. getRenderSize(): number;
  23435. /**
  23436. * Gets the actual render width of the texture.
  23437. * @returns the width of the render size
  23438. */
  23439. getRenderWidth(): number;
  23440. /**
  23441. * Gets the actual render height of the texture.
  23442. * @returns the height of the render size
  23443. */
  23444. getRenderHeight(): number;
  23445. /**
  23446. * Gets the actual number of layers of the texture.
  23447. * @returns the number of layers
  23448. */
  23449. getRenderLayers(): number;
  23450. /**
  23451. * Get if the texture can be rescaled or not.
  23452. */
  23453. get canRescale(): boolean;
  23454. /**
  23455. * Resize the texture using a ratio.
  23456. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23457. */
  23458. scale(ratio: number): void;
  23459. /**
  23460. * Get the texture reflection matrix used to rotate/transform the reflection.
  23461. * @returns the reflection matrix
  23462. */
  23463. getReflectionTextureMatrix(): Matrix;
  23464. /**
  23465. * Resize the texture to a new desired size.
  23466. * Be carrefull as it will recreate all the data in the new texture.
  23467. * @param size Define the new size. It can be:
  23468. * - a number for squared texture,
  23469. * - an object containing { width: number, height: number }
  23470. * - or an object containing a ratio { ratio: number }
  23471. */
  23472. resize(size: number | {
  23473. width: number;
  23474. height: number;
  23475. } | {
  23476. ratio: number;
  23477. }): void;
  23478. private _defaultRenderListPrepared;
  23479. /**
  23480. * Renders all the objects from the render list into the texture.
  23481. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23482. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23483. */
  23484. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23485. private _bestReflectionRenderTargetDimension;
  23486. private _prepareRenderingManager;
  23487. /**
  23488. * @hidden
  23489. * @param faceIndex face index to bind to if this is a cubetexture
  23490. * @param layer defines the index of the texture to bind in the array
  23491. */
  23492. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23493. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23494. private renderToTarget;
  23495. /**
  23496. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23497. * This allowed control for front to back rendering or reversly depending of the special needs.
  23498. *
  23499. * @param renderingGroupId The rendering group id corresponding to its index
  23500. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23501. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23502. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23503. */
  23504. 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;
  23505. /**
  23506. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23507. *
  23508. * @param renderingGroupId The rendering group id corresponding to its index
  23509. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23510. */
  23511. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23512. /**
  23513. * Clones the texture.
  23514. * @returns the cloned texture
  23515. */
  23516. clone(): RenderTargetTexture;
  23517. /**
  23518. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23519. * @returns The JSON representation of the texture
  23520. */
  23521. serialize(): any;
  23522. /**
  23523. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23524. */
  23525. disposeFramebufferObjects(): void;
  23526. /**
  23527. * Dispose the texture and release its associated resources.
  23528. */
  23529. dispose(): void;
  23530. /** @hidden */
  23531. _rebuild(): void;
  23532. /**
  23533. * Clear the info related to rendering groups preventing retention point in material dispose.
  23534. */
  23535. freeRenderingGroups(): void;
  23536. /**
  23537. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23538. * @returns the view count
  23539. */
  23540. getViewCount(): number;
  23541. }
  23542. }
  23543. declare module BABYLON {
  23544. /**
  23545. * Class used to manipulate GUIDs
  23546. */
  23547. export class GUID {
  23548. /**
  23549. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23550. * Be aware Math.random() could cause collisions, but:
  23551. * "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"
  23552. * @returns a pseudo random id
  23553. */
  23554. static RandomId(): string;
  23555. }
  23556. }
  23557. declare module BABYLON {
  23558. /**
  23559. * Options to be used when creating a shadow depth material
  23560. */
  23561. export interface IIOptionShadowDepthMaterial {
  23562. /** Variables in the vertex shader code that need to have their names remapped.
  23563. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23564. * "var_name" should be either: worldPos or vNormalW
  23565. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23566. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23567. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23568. */
  23569. remappedVariables?: string[];
  23570. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23571. standalone?: boolean;
  23572. }
  23573. /**
  23574. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23575. */
  23576. export class ShadowDepthWrapper {
  23577. private _scene;
  23578. private _options?;
  23579. private _baseMaterial;
  23580. private _onEffectCreatedObserver;
  23581. private _subMeshToEffect;
  23582. private _subMeshToDepthEffect;
  23583. private _meshes;
  23584. /** @hidden */
  23585. _matriceNames: any;
  23586. /** Gets the standalone status of the wrapper */
  23587. get standalone(): boolean;
  23588. /** Gets the base material the wrapper is built upon */
  23589. get baseMaterial(): Material;
  23590. /**
  23591. * Instantiate a new shadow depth wrapper.
  23592. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23593. * generate the shadow depth map. For more information, please refer to the documentation:
  23594. * https://doc.babylonjs.com/babylon101/shadows
  23595. * @param baseMaterial Material to wrap
  23596. * @param scene Define the scene the material belongs to
  23597. * @param options Options used to create the wrapper
  23598. */
  23599. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23600. /**
  23601. * Gets the effect to use to generate the depth map
  23602. * @param subMesh subMesh to get the effect for
  23603. * @param shadowGenerator shadow generator to get the effect for
  23604. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23605. */
  23606. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23607. /**
  23608. * Specifies that the submesh is ready to be used for depth rendering
  23609. * @param subMesh submesh to check
  23610. * @param defines the list of defines to take into account when checking the effect
  23611. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23612. * @param useInstances specifies that instances should be used
  23613. * @returns a boolean indicating that the submesh is ready or not
  23614. */
  23615. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23616. /**
  23617. * Disposes the resources
  23618. */
  23619. dispose(): void;
  23620. private _makeEffect;
  23621. }
  23622. }
  23623. declare module BABYLON {
  23624. /**
  23625. * Options for compiling materials.
  23626. */
  23627. export interface IMaterialCompilationOptions {
  23628. /**
  23629. * Defines whether clip planes are enabled.
  23630. */
  23631. clipPlane: boolean;
  23632. /**
  23633. * Defines whether instances are enabled.
  23634. */
  23635. useInstances: boolean;
  23636. }
  23637. /**
  23638. * Options passed when calling customShaderNameResolve
  23639. */
  23640. export interface ICustomShaderNameResolveOptions {
  23641. /**
  23642. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  23643. */
  23644. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23645. }
  23646. /**
  23647. * Base class for the main features of a material in Babylon.js
  23648. */
  23649. export class Material implements IAnimatable {
  23650. /**
  23651. * Returns the triangle fill mode
  23652. */
  23653. static readonly TriangleFillMode: number;
  23654. /**
  23655. * Returns the wireframe mode
  23656. */
  23657. static readonly WireFrameFillMode: number;
  23658. /**
  23659. * Returns the point fill mode
  23660. */
  23661. static readonly PointFillMode: number;
  23662. /**
  23663. * Returns the point list draw mode
  23664. */
  23665. static readonly PointListDrawMode: number;
  23666. /**
  23667. * Returns the line list draw mode
  23668. */
  23669. static readonly LineListDrawMode: number;
  23670. /**
  23671. * Returns the line loop draw mode
  23672. */
  23673. static readonly LineLoopDrawMode: number;
  23674. /**
  23675. * Returns the line strip draw mode
  23676. */
  23677. static readonly LineStripDrawMode: number;
  23678. /**
  23679. * Returns the triangle strip draw mode
  23680. */
  23681. static readonly TriangleStripDrawMode: number;
  23682. /**
  23683. * Returns the triangle fan draw mode
  23684. */
  23685. static readonly TriangleFanDrawMode: number;
  23686. /**
  23687. * Stores the clock-wise side orientation
  23688. */
  23689. static readonly ClockWiseSideOrientation: number;
  23690. /**
  23691. * Stores the counter clock-wise side orientation
  23692. */
  23693. static readonly CounterClockWiseSideOrientation: number;
  23694. /**
  23695. * The dirty texture flag value
  23696. */
  23697. static readonly TextureDirtyFlag: number;
  23698. /**
  23699. * The dirty light flag value
  23700. */
  23701. static readonly LightDirtyFlag: number;
  23702. /**
  23703. * The dirty fresnel flag value
  23704. */
  23705. static readonly FresnelDirtyFlag: number;
  23706. /**
  23707. * The dirty attribute flag value
  23708. */
  23709. static readonly AttributesDirtyFlag: number;
  23710. /**
  23711. * The dirty misc flag value
  23712. */
  23713. static readonly MiscDirtyFlag: number;
  23714. /**
  23715. * The all dirty flag value
  23716. */
  23717. static readonly AllDirtyFlag: number;
  23718. /**
  23719. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23720. */
  23721. static readonly MATERIAL_OPAQUE: number;
  23722. /**
  23723. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23724. */
  23725. static readonly MATERIAL_ALPHATEST: number;
  23726. /**
  23727. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23728. */
  23729. static readonly MATERIAL_ALPHABLEND: number;
  23730. /**
  23731. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23732. * They are also discarded below the alpha cutoff threshold to improve performances.
  23733. */
  23734. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23735. /**
  23736. * Custom callback helping to override the default shader used in the material.
  23737. */
  23738. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23739. /**
  23740. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23741. */
  23742. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23743. /**
  23744. * The ID of the material
  23745. */
  23746. id: string;
  23747. /**
  23748. * Gets or sets the unique id of the material
  23749. */
  23750. uniqueId: number;
  23751. /**
  23752. * The name of the material
  23753. */
  23754. name: string;
  23755. /**
  23756. * Gets or sets user defined metadata
  23757. */
  23758. metadata: any;
  23759. /**
  23760. * For internal use only. Please do not use.
  23761. */
  23762. reservedDataStore: any;
  23763. /**
  23764. * Specifies if the ready state should be checked on each call
  23765. */
  23766. checkReadyOnEveryCall: boolean;
  23767. /**
  23768. * Specifies if the ready state should be checked once
  23769. */
  23770. checkReadyOnlyOnce: boolean;
  23771. /**
  23772. * The state of the material
  23773. */
  23774. state: string;
  23775. /**
  23776. * The alpha value of the material
  23777. */
  23778. protected _alpha: number;
  23779. /**
  23780. * List of inspectable custom properties (used by the Inspector)
  23781. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23782. */
  23783. inspectableCustomProperties: IInspectable[];
  23784. /**
  23785. * Sets the alpha value of the material
  23786. */
  23787. set alpha(value: number);
  23788. /**
  23789. * Gets the alpha value of the material
  23790. */
  23791. get alpha(): number;
  23792. /**
  23793. * Specifies if back face culling is enabled
  23794. */
  23795. protected _backFaceCulling: boolean;
  23796. /**
  23797. * Sets the back-face culling state
  23798. */
  23799. set backFaceCulling(value: boolean);
  23800. /**
  23801. * Gets the back-face culling state
  23802. */
  23803. get backFaceCulling(): boolean;
  23804. /**
  23805. * Stores the value for side orientation
  23806. */
  23807. sideOrientation: number;
  23808. /**
  23809. * Callback triggered when the material is compiled
  23810. */
  23811. onCompiled: Nullable<(effect: Effect) => void>;
  23812. /**
  23813. * Callback triggered when an error occurs
  23814. */
  23815. onError: Nullable<(effect: Effect, errors: string) => void>;
  23816. /**
  23817. * Callback triggered to get the render target textures
  23818. */
  23819. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23820. /**
  23821. * Gets a boolean indicating that current material needs to register RTT
  23822. */
  23823. get hasRenderTargetTextures(): boolean;
  23824. /**
  23825. * Specifies if the material should be serialized
  23826. */
  23827. doNotSerialize: boolean;
  23828. /**
  23829. * @hidden
  23830. */
  23831. _storeEffectOnSubMeshes: boolean;
  23832. /**
  23833. * Stores the animations for the material
  23834. */
  23835. animations: Nullable<Array<Animation>>;
  23836. /**
  23837. * An event triggered when the material is disposed
  23838. */
  23839. onDisposeObservable: Observable<Material>;
  23840. /**
  23841. * An observer which watches for dispose events
  23842. */
  23843. private _onDisposeObserver;
  23844. private _onUnBindObservable;
  23845. /**
  23846. * Called during a dispose event
  23847. */
  23848. set onDispose(callback: () => void);
  23849. private _onBindObservable;
  23850. /**
  23851. * An event triggered when the material is bound
  23852. */
  23853. get onBindObservable(): Observable<AbstractMesh>;
  23854. /**
  23855. * An observer which watches for bind events
  23856. */
  23857. private _onBindObserver;
  23858. /**
  23859. * Called during a bind event
  23860. */
  23861. set onBind(callback: (Mesh: AbstractMesh) => void);
  23862. /**
  23863. * An event triggered when the material is unbound
  23864. */
  23865. get onUnBindObservable(): Observable<Material>;
  23866. protected _onEffectCreatedObservable: Nullable<Observable<{
  23867. effect: Effect;
  23868. subMesh: Nullable<SubMesh>;
  23869. }>>;
  23870. /**
  23871. * An event triggered when the effect is (re)created
  23872. */
  23873. get onEffectCreatedObservable(): Observable<{
  23874. effect: Effect;
  23875. subMesh: Nullable<SubMesh>;
  23876. }>;
  23877. /**
  23878. * Stores the value of the alpha mode
  23879. */
  23880. private _alphaMode;
  23881. /**
  23882. * Sets the value of the alpha mode.
  23883. *
  23884. * | Value | Type | Description |
  23885. * | --- | --- | --- |
  23886. * | 0 | ALPHA_DISABLE | |
  23887. * | 1 | ALPHA_ADD | |
  23888. * | 2 | ALPHA_COMBINE | |
  23889. * | 3 | ALPHA_SUBTRACT | |
  23890. * | 4 | ALPHA_MULTIPLY | |
  23891. * | 5 | ALPHA_MAXIMIZED | |
  23892. * | 6 | ALPHA_ONEONE | |
  23893. * | 7 | ALPHA_PREMULTIPLIED | |
  23894. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23895. * | 9 | ALPHA_INTERPOLATE | |
  23896. * | 10 | ALPHA_SCREENMODE | |
  23897. *
  23898. */
  23899. set alphaMode(value: number);
  23900. /**
  23901. * Gets the value of the alpha mode
  23902. */
  23903. get alphaMode(): number;
  23904. /**
  23905. * Stores the state of the need depth pre-pass value
  23906. */
  23907. private _needDepthPrePass;
  23908. /**
  23909. * Sets the need depth pre-pass value
  23910. */
  23911. set needDepthPrePass(value: boolean);
  23912. /**
  23913. * Gets the depth pre-pass value
  23914. */
  23915. get needDepthPrePass(): boolean;
  23916. /**
  23917. * Specifies if depth writing should be disabled
  23918. */
  23919. disableDepthWrite: boolean;
  23920. /**
  23921. * Specifies if color writing should be disabled
  23922. */
  23923. disableColorWrite: boolean;
  23924. /**
  23925. * Specifies if depth writing should be forced
  23926. */
  23927. forceDepthWrite: boolean;
  23928. /**
  23929. * Specifies the depth function that should be used. 0 means the default engine function
  23930. */
  23931. depthFunction: number;
  23932. /**
  23933. * Specifies if there should be a separate pass for culling
  23934. */
  23935. separateCullingPass: boolean;
  23936. /**
  23937. * Stores the state specifing if fog should be enabled
  23938. */
  23939. private _fogEnabled;
  23940. /**
  23941. * Sets the state for enabling fog
  23942. */
  23943. set fogEnabled(value: boolean);
  23944. /**
  23945. * Gets the value of the fog enabled state
  23946. */
  23947. get fogEnabled(): boolean;
  23948. /**
  23949. * Stores the size of points
  23950. */
  23951. pointSize: number;
  23952. /**
  23953. * Stores the z offset value
  23954. */
  23955. zOffset: number;
  23956. get wireframe(): boolean;
  23957. /**
  23958. * Sets the state of wireframe mode
  23959. */
  23960. set wireframe(value: boolean);
  23961. /**
  23962. * Gets the value specifying if point clouds are enabled
  23963. */
  23964. get pointsCloud(): boolean;
  23965. /**
  23966. * Sets the state of point cloud mode
  23967. */
  23968. set pointsCloud(value: boolean);
  23969. /**
  23970. * Gets the material fill mode
  23971. */
  23972. get fillMode(): number;
  23973. /**
  23974. * Sets the material fill mode
  23975. */
  23976. set fillMode(value: number);
  23977. /**
  23978. * @hidden
  23979. * Stores the effects for the material
  23980. */
  23981. _effect: Nullable<Effect>;
  23982. /**
  23983. * Specifies if uniform buffers should be used
  23984. */
  23985. private _useUBO;
  23986. /**
  23987. * Stores a reference to the scene
  23988. */
  23989. private _scene;
  23990. /**
  23991. * Stores the fill mode state
  23992. */
  23993. private _fillMode;
  23994. /**
  23995. * Specifies if the depth write state should be cached
  23996. */
  23997. private _cachedDepthWriteState;
  23998. /**
  23999. * Specifies if the color write state should be cached
  24000. */
  24001. private _cachedColorWriteState;
  24002. /**
  24003. * Specifies if the depth function state should be cached
  24004. */
  24005. private _cachedDepthFunctionState;
  24006. /**
  24007. * Stores the uniform buffer
  24008. */
  24009. protected _uniformBuffer: UniformBuffer;
  24010. /** @hidden */
  24011. _indexInSceneMaterialArray: number;
  24012. /** @hidden */
  24013. meshMap: Nullable<{
  24014. [id: string]: AbstractMesh | undefined;
  24015. }>;
  24016. /**
  24017. * Creates a material instance
  24018. * @param name defines the name of the material
  24019. * @param scene defines the scene to reference
  24020. * @param doNotAdd specifies if the material should be added to the scene
  24021. */
  24022. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24023. /**
  24024. * Returns a string representation of the current material
  24025. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24026. * @returns a string with material information
  24027. */
  24028. toString(fullDetails?: boolean): string;
  24029. /**
  24030. * Gets the class name of the material
  24031. * @returns a string with the class name of the material
  24032. */
  24033. getClassName(): string;
  24034. /**
  24035. * Specifies if updates for the material been locked
  24036. */
  24037. get isFrozen(): boolean;
  24038. /**
  24039. * Locks updates for the material
  24040. */
  24041. freeze(): void;
  24042. /**
  24043. * Unlocks updates for the material
  24044. */
  24045. unfreeze(): void;
  24046. /**
  24047. * Specifies if the material is ready to be used
  24048. * @param mesh defines the mesh to check
  24049. * @param useInstances specifies if instances should be used
  24050. * @returns a boolean indicating if the material is ready to be used
  24051. */
  24052. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24053. /**
  24054. * Specifies that the submesh is ready to be used
  24055. * @param mesh defines the mesh to check
  24056. * @param subMesh defines which submesh to check
  24057. * @param useInstances specifies that instances should be used
  24058. * @returns a boolean indicating that the submesh is ready or not
  24059. */
  24060. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24061. /**
  24062. * Returns the material effect
  24063. * @returns the effect associated with the material
  24064. */
  24065. getEffect(): Nullable<Effect>;
  24066. /**
  24067. * Returns the current scene
  24068. * @returns a Scene
  24069. */
  24070. getScene(): Scene;
  24071. /**
  24072. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24073. */
  24074. protected _forceAlphaTest: boolean;
  24075. /**
  24076. * The transparency mode of the material.
  24077. */
  24078. protected _transparencyMode: Nullable<number>;
  24079. /**
  24080. * Gets the current transparency mode.
  24081. */
  24082. get transparencyMode(): Nullable<number>;
  24083. /**
  24084. * Sets the transparency mode of the material.
  24085. *
  24086. * | Value | Type | Description |
  24087. * | ----- | ----------------------------------- | ----------- |
  24088. * | 0 | OPAQUE | |
  24089. * | 1 | ALPHATEST | |
  24090. * | 2 | ALPHABLEND | |
  24091. * | 3 | ALPHATESTANDBLEND | |
  24092. *
  24093. */
  24094. set transparencyMode(value: Nullable<number>);
  24095. /**
  24096. * Returns true if alpha blending should be disabled.
  24097. */
  24098. protected get _disableAlphaBlending(): boolean;
  24099. /**
  24100. * Specifies whether or not this material should be rendered in alpha blend mode.
  24101. * @returns a boolean specifying if alpha blending is needed
  24102. */
  24103. needAlphaBlending(): boolean;
  24104. /**
  24105. * Specifies if the mesh will require alpha blending
  24106. * @param mesh defines the mesh to check
  24107. * @returns a boolean specifying if alpha blending is needed for the mesh
  24108. */
  24109. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24110. /**
  24111. * Specifies whether or not this material should be rendered in alpha test mode.
  24112. * @returns a boolean specifying if an alpha test is needed.
  24113. */
  24114. needAlphaTesting(): boolean;
  24115. /**
  24116. * Specifies if material alpha testing should be turned on for the mesh
  24117. * @param mesh defines the mesh to check
  24118. */
  24119. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24120. /**
  24121. * Gets the texture used for the alpha test
  24122. * @returns the texture to use for alpha testing
  24123. */
  24124. getAlphaTestTexture(): Nullable<BaseTexture>;
  24125. /**
  24126. * Marks the material to indicate that it needs to be re-calculated
  24127. */
  24128. markDirty(): void;
  24129. /** @hidden */
  24130. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24131. /**
  24132. * Binds the material to the mesh
  24133. * @param world defines the world transformation matrix
  24134. * @param mesh defines the mesh to bind the material to
  24135. */
  24136. bind(world: Matrix, mesh?: Mesh): void;
  24137. /**
  24138. * Binds the submesh to the material
  24139. * @param world defines the world transformation matrix
  24140. * @param mesh defines the mesh containing the submesh
  24141. * @param subMesh defines the submesh to bind the material to
  24142. */
  24143. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24144. /**
  24145. * Binds the world matrix to the material
  24146. * @param world defines the world transformation matrix
  24147. */
  24148. bindOnlyWorldMatrix(world: Matrix): void;
  24149. /**
  24150. * Binds the scene's uniform buffer to the effect.
  24151. * @param effect defines the effect to bind to the scene uniform buffer
  24152. * @param sceneUbo defines the uniform buffer storing scene data
  24153. */
  24154. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24155. /**
  24156. * Binds the view matrix to the effect
  24157. * @param effect defines the effect to bind the view matrix to
  24158. */
  24159. bindView(effect: Effect): void;
  24160. /**
  24161. * Binds the view projection matrix to the effect
  24162. * @param effect defines the effect to bind the view projection matrix to
  24163. */
  24164. bindViewProjection(effect: Effect): void;
  24165. /**
  24166. * Processes to execute after binding the material to a mesh
  24167. * @param mesh defines the rendered mesh
  24168. */
  24169. protected _afterBind(mesh?: Mesh): void;
  24170. /**
  24171. * Unbinds the material from the mesh
  24172. */
  24173. unbind(): void;
  24174. /**
  24175. * Gets the active textures from the material
  24176. * @returns an array of textures
  24177. */
  24178. getActiveTextures(): BaseTexture[];
  24179. /**
  24180. * Specifies if the material uses a texture
  24181. * @param texture defines the texture to check against the material
  24182. * @returns a boolean specifying if the material uses the texture
  24183. */
  24184. hasTexture(texture: BaseTexture): boolean;
  24185. /**
  24186. * Makes a duplicate of the material, and gives it a new name
  24187. * @param name defines the new name for the duplicated material
  24188. * @returns the cloned material
  24189. */
  24190. clone(name: string): Nullable<Material>;
  24191. /**
  24192. * Gets the meshes bound to the material
  24193. * @returns an array of meshes bound to the material
  24194. */
  24195. getBindedMeshes(): AbstractMesh[];
  24196. /**
  24197. * Force shader compilation
  24198. * @param mesh defines the mesh associated with this material
  24199. * @param onCompiled defines a function to execute once the material is compiled
  24200. * @param options defines the options to configure the compilation
  24201. * @param onError defines a function to execute if the material fails compiling
  24202. */
  24203. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24204. /**
  24205. * Force shader compilation
  24206. * @param mesh defines the mesh that will use this material
  24207. * @param options defines additional options for compiling the shaders
  24208. * @returns a promise that resolves when the compilation completes
  24209. */
  24210. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24211. private static readonly _AllDirtyCallBack;
  24212. private static readonly _ImageProcessingDirtyCallBack;
  24213. private static readonly _TextureDirtyCallBack;
  24214. private static readonly _FresnelDirtyCallBack;
  24215. private static readonly _MiscDirtyCallBack;
  24216. private static readonly _LightsDirtyCallBack;
  24217. private static readonly _AttributeDirtyCallBack;
  24218. private static _FresnelAndMiscDirtyCallBack;
  24219. private static _TextureAndMiscDirtyCallBack;
  24220. private static readonly _DirtyCallbackArray;
  24221. private static readonly _RunDirtyCallBacks;
  24222. /**
  24223. * Marks a define in the material to indicate that it needs to be re-computed
  24224. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24225. */
  24226. markAsDirty(flag: number): void;
  24227. /**
  24228. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24229. * @param func defines a function which checks material defines against the submeshes
  24230. */
  24231. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24232. /**
  24233. * Indicates that we need to re-calculated for all submeshes
  24234. */
  24235. protected _markAllSubMeshesAsAllDirty(): void;
  24236. /**
  24237. * Indicates that image processing needs to be re-calculated for all submeshes
  24238. */
  24239. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24240. /**
  24241. * Indicates that textures need to be re-calculated for all submeshes
  24242. */
  24243. protected _markAllSubMeshesAsTexturesDirty(): void;
  24244. /**
  24245. * Indicates that fresnel needs to be re-calculated for all submeshes
  24246. */
  24247. protected _markAllSubMeshesAsFresnelDirty(): void;
  24248. /**
  24249. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24250. */
  24251. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24252. /**
  24253. * Indicates that lights need to be re-calculated for all submeshes
  24254. */
  24255. protected _markAllSubMeshesAsLightsDirty(): void;
  24256. /**
  24257. * Indicates that attributes need to be re-calculated for all submeshes
  24258. */
  24259. protected _markAllSubMeshesAsAttributesDirty(): void;
  24260. /**
  24261. * Indicates that misc needs to be re-calculated for all submeshes
  24262. */
  24263. protected _markAllSubMeshesAsMiscDirty(): void;
  24264. /**
  24265. * Indicates that textures and misc need to be re-calculated for all submeshes
  24266. */
  24267. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24268. /**
  24269. * Disposes the material
  24270. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24271. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24272. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24273. */
  24274. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24275. /** @hidden */
  24276. private releaseVertexArrayObject;
  24277. /**
  24278. * Serializes this material
  24279. * @returns the serialized material object
  24280. */
  24281. serialize(): any;
  24282. /**
  24283. * Creates a material from parsed material data
  24284. * @param parsedMaterial defines parsed material data
  24285. * @param scene defines the hosting scene
  24286. * @param rootUrl defines the root URL to use to load textures
  24287. * @returns a new material
  24288. */
  24289. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24290. }
  24291. }
  24292. declare module BABYLON {
  24293. /**
  24294. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24295. * separate meshes. This can be use to improve performances.
  24296. * @see http://doc.babylonjs.com/how_to/multi_materials
  24297. */
  24298. export class MultiMaterial extends Material {
  24299. private _subMaterials;
  24300. /**
  24301. * Gets or Sets the list of Materials used within the multi material.
  24302. * They need to be ordered according to the submeshes order in the associated mesh
  24303. */
  24304. get subMaterials(): Nullable<Material>[];
  24305. set subMaterials(value: Nullable<Material>[]);
  24306. /**
  24307. * Function used to align with Node.getChildren()
  24308. * @returns the list of Materials used within the multi material
  24309. */
  24310. getChildren(): Nullable<Material>[];
  24311. /**
  24312. * Instantiates a new Multi Material
  24313. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24314. * separate meshes. This can be use to improve performances.
  24315. * @see http://doc.babylonjs.com/how_to/multi_materials
  24316. * @param name Define the name in the scene
  24317. * @param scene Define the scene the material belongs to
  24318. */
  24319. constructor(name: string, scene: Scene);
  24320. private _hookArray;
  24321. /**
  24322. * Get one of the submaterial by its index in the submaterials array
  24323. * @param index The index to look the sub material at
  24324. * @returns The Material if the index has been defined
  24325. */
  24326. getSubMaterial(index: number): Nullable<Material>;
  24327. /**
  24328. * Get the list of active textures for the whole sub materials list.
  24329. * @returns All the textures that will be used during the rendering
  24330. */
  24331. getActiveTextures(): BaseTexture[];
  24332. /**
  24333. * Gets the current class name of the material e.g. "MultiMaterial"
  24334. * Mainly use in serialization.
  24335. * @returns the class name
  24336. */
  24337. getClassName(): string;
  24338. /**
  24339. * Checks if the material is ready to render the requested sub mesh
  24340. * @param mesh Define the mesh the submesh belongs to
  24341. * @param subMesh Define the sub mesh to look readyness for
  24342. * @param useInstances Define whether or not the material is used with instances
  24343. * @returns true if ready, otherwise false
  24344. */
  24345. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24346. /**
  24347. * Clones the current material and its related sub materials
  24348. * @param name Define the name of the newly cloned material
  24349. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24350. * @returns the cloned material
  24351. */
  24352. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24353. /**
  24354. * Serializes the materials into a JSON representation.
  24355. * @returns the JSON representation
  24356. */
  24357. serialize(): any;
  24358. /**
  24359. * Dispose the material and release its associated resources
  24360. * @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)
  24361. * @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)
  24362. * @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)
  24363. */
  24364. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24365. /**
  24366. * Creates a MultiMaterial from parsed MultiMaterial data.
  24367. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24368. * @param scene defines the hosting scene
  24369. * @returns a new MultiMaterial
  24370. */
  24371. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24372. }
  24373. }
  24374. declare module BABYLON {
  24375. /**
  24376. * Defines a subdivision inside a mesh
  24377. */
  24378. export class SubMesh implements ICullable {
  24379. /** the material index to use */
  24380. materialIndex: number;
  24381. /** vertex index start */
  24382. verticesStart: number;
  24383. /** vertices count */
  24384. verticesCount: number;
  24385. /** index start */
  24386. indexStart: number;
  24387. /** indices count */
  24388. indexCount: number;
  24389. /** @hidden */
  24390. _materialDefines: Nullable<MaterialDefines>;
  24391. /** @hidden */
  24392. _materialEffect: Nullable<Effect>;
  24393. /** @hidden */
  24394. _effectOverride: Nullable<Effect>;
  24395. /**
  24396. * Gets material defines used by the effect associated to the sub mesh
  24397. */
  24398. get materialDefines(): Nullable<MaterialDefines>;
  24399. /**
  24400. * Sets material defines used by the effect associated to the sub mesh
  24401. */
  24402. set materialDefines(defines: Nullable<MaterialDefines>);
  24403. /**
  24404. * Gets associated effect
  24405. */
  24406. get effect(): Nullable<Effect>;
  24407. /**
  24408. * Sets associated effect (effect used to render this submesh)
  24409. * @param effect defines the effect to associate with
  24410. * @param defines defines the set of defines used to compile this effect
  24411. */
  24412. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24413. /** @hidden */
  24414. _linesIndexCount: number;
  24415. private _mesh;
  24416. private _renderingMesh;
  24417. private _boundingInfo;
  24418. private _linesIndexBuffer;
  24419. /** @hidden */
  24420. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24421. /** @hidden */
  24422. _trianglePlanes: Plane[];
  24423. /** @hidden */
  24424. _lastColliderTransformMatrix: Nullable<Matrix>;
  24425. /** @hidden */
  24426. _renderId: number;
  24427. /** @hidden */
  24428. _alphaIndex: number;
  24429. /** @hidden */
  24430. _distanceToCamera: number;
  24431. /** @hidden */
  24432. _id: number;
  24433. private _currentMaterial;
  24434. /**
  24435. * Add a new submesh to a mesh
  24436. * @param materialIndex defines the material index to use
  24437. * @param verticesStart defines vertex index start
  24438. * @param verticesCount defines vertices count
  24439. * @param indexStart defines index start
  24440. * @param indexCount defines indices count
  24441. * @param mesh defines the parent mesh
  24442. * @param renderingMesh defines an optional rendering mesh
  24443. * @param createBoundingBox defines if bounding box should be created for this submesh
  24444. * @returns the new submesh
  24445. */
  24446. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24447. /**
  24448. * Creates a new submesh
  24449. * @param materialIndex defines the material index to use
  24450. * @param verticesStart defines vertex index start
  24451. * @param verticesCount defines vertices count
  24452. * @param indexStart defines index start
  24453. * @param indexCount defines indices count
  24454. * @param mesh defines the parent mesh
  24455. * @param renderingMesh defines an optional rendering mesh
  24456. * @param createBoundingBox defines if bounding box should be created for this submesh
  24457. */
  24458. constructor(
  24459. /** the material index to use */
  24460. materialIndex: number,
  24461. /** vertex index start */
  24462. verticesStart: number,
  24463. /** vertices count */
  24464. verticesCount: number,
  24465. /** index start */
  24466. indexStart: number,
  24467. /** indices count */
  24468. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  24469. /**
  24470. * Returns true if this submesh covers the entire parent mesh
  24471. * @ignorenaming
  24472. */
  24473. get IsGlobal(): boolean;
  24474. /**
  24475. * Returns the submesh BoudingInfo object
  24476. * @returns current bounding info (or mesh's one if the submesh is global)
  24477. */
  24478. getBoundingInfo(): BoundingInfo;
  24479. /**
  24480. * Sets the submesh BoundingInfo
  24481. * @param boundingInfo defines the new bounding info to use
  24482. * @returns the SubMesh
  24483. */
  24484. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24485. /**
  24486. * Returns the mesh of the current submesh
  24487. * @return the parent mesh
  24488. */
  24489. getMesh(): AbstractMesh;
  24490. /**
  24491. * Returns the rendering mesh of the submesh
  24492. * @returns the rendering mesh (could be different from parent mesh)
  24493. */
  24494. getRenderingMesh(): Mesh;
  24495. /**
  24496. * Returns the replacement mesh of the submesh
  24497. * @returns the replacement mesh (could be different from parent mesh)
  24498. */
  24499. getReplacementMesh(): Nullable<AbstractMesh>;
  24500. /**
  24501. * Returns the effective mesh of the submesh
  24502. * @returns the effective mesh (could be different from parent mesh)
  24503. */
  24504. getEffectiveMesh(): AbstractMesh;
  24505. /**
  24506. * Returns the submesh material
  24507. * @returns null or the current material
  24508. */
  24509. getMaterial(): Nullable<Material>;
  24510. /**
  24511. * Sets a new updated BoundingInfo object to the submesh
  24512. * @param data defines an optional position array to use to determine the bounding info
  24513. * @returns the SubMesh
  24514. */
  24515. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24516. /** @hidden */
  24517. _checkCollision(collider: Collider): boolean;
  24518. /**
  24519. * Updates the submesh BoundingInfo
  24520. * @param world defines the world matrix to use to update the bounding info
  24521. * @returns the submesh
  24522. */
  24523. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24524. /**
  24525. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24526. * @param frustumPlanes defines the frustum planes
  24527. * @returns true if the submesh is intersecting with the frustum
  24528. */
  24529. isInFrustum(frustumPlanes: Plane[]): boolean;
  24530. /**
  24531. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24532. * @param frustumPlanes defines the frustum planes
  24533. * @returns true if the submesh is inside the frustum
  24534. */
  24535. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24536. /**
  24537. * Renders the submesh
  24538. * @param enableAlphaMode defines if alpha needs to be used
  24539. * @returns the submesh
  24540. */
  24541. render(enableAlphaMode: boolean): SubMesh;
  24542. /**
  24543. * @hidden
  24544. */
  24545. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24546. /**
  24547. * Checks if the submesh intersects with a ray
  24548. * @param ray defines the ray to test
  24549. * @returns true is the passed ray intersects the submesh bounding box
  24550. */
  24551. canIntersects(ray: Ray): boolean;
  24552. /**
  24553. * Intersects current submesh with a ray
  24554. * @param ray defines the ray to test
  24555. * @param positions defines mesh's positions array
  24556. * @param indices defines mesh's indices array
  24557. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24558. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24559. * @returns intersection info or null if no intersection
  24560. */
  24561. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24562. /** @hidden */
  24563. private _intersectLines;
  24564. /** @hidden */
  24565. private _intersectUnIndexedLines;
  24566. /** @hidden */
  24567. private _intersectTriangles;
  24568. /** @hidden */
  24569. private _intersectUnIndexedTriangles;
  24570. /** @hidden */
  24571. _rebuild(): void;
  24572. /**
  24573. * Creates a new submesh from the passed mesh
  24574. * @param newMesh defines the new hosting mesh
  24575. * @param newRenderingMesh defines an optional rendering mesh
  24576. * @returns the new submesh
  24577. */
  24578. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24579. /**
  24580. * Release associated resources
  24581. */
  24582. dispose(): void;
  24583. /**
  24584. * Gets the class name
  24585. * @returns the string "SubMesh".
  24586. */
  24587. getClassName(): string;
  24588. /**
  24589. * Creates a new submesh from indices data
  24590. * @param materialIndex the index of the main mesh material
  24591. * @param startIndex the index where to start the copy in the mesh indices array
  24592. * @param indexCount the number of indices to copy then from the startIndex
  24593. * @param mesh the main mesh to create the submesh from
  24594. * @param renderingMesh the optional rendering mesh
  24595. * @returns a new submesh
  24596. */
  24597. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24598. }
  24599. }
  24600. declare module BABYLON {
  24601. /**
  24602. * Class used to represent data loading progression
  24603. */
  24604. export class SceneLoaderFlags {
  24605. private static _ForceFullSceneLoadingForIncremental;
  24606. private static _ShowLoadingScreen;
  24607. private static _CleanBoneMatrixWeights;
  24608. private static _loggingLevel;
  24609. /**
  24610. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24611. */
  24612. static get ForceFullSceneLoadingForIncremental(): boolean;
  24613. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24614. /**
  24615. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24616. */
  24617. static get ShowLoadingScreen(): boolean;
  24618. static set ShowLoadingScreen(value: boolean);
  24619. /**
  24620. * Defines the current logging level (while loading the scene)
  24621. * @ignorenaming
  24622. */
  24623. static get loggingLevel(): number;
  24624. static set loggingLevel(value: number);
  24625. /**
  24626. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24627. */
  24628. static get CleanBoneMatrixWeights(): boolean;
  24629. static set CleanBoneMatrixWeights(value: boolean);
  24630. }
  24631. }
  24632. declare module BABYLON {
  24633. /**
  24634. * Class used to store geometry data (vertex buffers + index buffer)
  24635. */
  24636. export class Geometry implements IGetSetVerticesData {
  24637. /**
  24638. * Gets or sets the ID of the geometry
  24639. */
  24640. id: string;
  24641. /**
  24642. * Gets or sets the unique ID of the geometry
  24643. */
  24644. uniqueId: number;
  24645. /**
  24646. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24647. */
  24648. delayLoadState: number;
  24649. /**
  24650. * Gets the file containing the data to load when running in delay load state
  24651. */
  24652. delayLoadingFile: Nullable<string>;
  24653. /**
  24654. * Callback called when the geometry is updated
  24655. */
  24656. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24657. private _scene;
  24658. private _engine;
  24659. private _meshes;
  24660. private _totalVertices;
  24661. /** @hidden */
  24662. _indices: IndicesArray;
  24663. /** @hidden */
  24664. _vertexBuffers: {
  24665. [key: string]: VertexBuffer;
  24666. };
  24667. private _isDisposed;
  24668. private _extend;
  24669. private _boundingBias;
  24670. /** @hidden */
  24671. _delayInfo: Array<string>;
  24672. private _indexBuffer;
  24673. private _indexBufferIsUpdatable;
  24674. /** @hidden */
  24675. _boundingInfo: Nullable<BoundingInfo>;
  24676. /** @hidden */
  24677. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24678. /** @hidden */
  24679. _softwareSkinningFrameId: number;
  24680. private _vertexArrayObjects;
  24681. private _updatable;
  24682. /** @hidden */
  24683. _positions: Nullable<Vector3[]>;
  24684. /**
  24685. * 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
  24686. */
  24687. get boundingBias(): Vector2;
  24688. /**
  24689. * 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
  24690. */
  24691. set boundingBias(value: Vector2);
  24692. /**
  24693. * Static function used to attach a new empty geometry to a mesh
  24694. * @param mesh defines the mesh to attach the geometry to
  24695. * @returns the new Geometry
  24696. */
  24697. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24698. /** Get the list of meshes using this geometry */
  24699. get meshes(): Mesh[];
  24700. /**
  24701. * Creates a new geometry
  24702. * @param id defines the unique ID
  24703. * @param scene defines the hosting scene
  24704. * @param vertexData defines the VertexData used to get geometry data
  24705. * @param updatable defines if geometry must be updatable (false by default)
  24706. * @param mesh defines the mesh that will be associated with the geometry
  24707. */
  24708. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24709. /**
  24710. * Gets the current extend of the geometry
  24711. */
  24712. get extend(): {
  24713. minimum: Vector3;
  24714. maximum: Vector3;
  24715. };
  24716. /**
  24717. * Gets the hosting scene
  24718. * @returns the hosting Scene
  24719. */
  24720. getScene(): Scene;
  24721. /**
  24722. * Gets the hosting engine
  24723. * @returns the hosting Engine
  24724. */
  24725. getEngine(): Engine;
  24726. /**
  24727. * Defines if the geometry is ready to use
  24728. * @returns true if the geometry is ready to be used
  24729. */
  24730. isReady(): boolean;
  24731. /**
  24732. * Gets a value indicating that the geometry should not be serialized
  24733. */
  24734. get doNotSerialize(): boolean;
  24735. /** @hidden */
  24736. _rebuild(): void;
  24737. /**
  24738. * Affects all geometry data in one call
  24739. * @param vertexData defines the geometry data
  24740. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24741. */
  24742. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24743. /**
  24744. * Set specific vertex data
  24745. * @param kind defines the data kind (Position, normal, etc...)
  24746. * @param data defines the vertex data to use
  24747. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24748. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24749. */
  24750. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24751. /**
  24752. * Removes a specific vertex data
  24753. * @param kind defines the data kind (Position, normal, etc...)
  24754. */
  24755. removeVerticesData(kind: string): void;
  24756. /**
  24757. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24758. * @param buffer defines the vertex buffer to use
  24759. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24760. */
  24761. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24762. /**
  24763. * Update a specific vertex buffer
  24764. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24765. * It will do nothing if the buffer is not updatable
  24766. * @param kind defines the data kind (Position, normal, etc...)
  24767. * @param data defines the data to use
  24768. * @param offset defines the offset in the target buffer where to store the data
  24769. * @param useBytes set to true if the offset is in bytes
  24770. */
  24771. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24772. /**
  24773. * Update a specific vertex buffer
  24774. * This function will create a new buffer if the current one is not updatable
  24775. * @param kind defines the data kind (Position, normal, etc...)
  24776. * @param data defines the data to use
  24777. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24778. */
  24779. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24780. private _updateBoundingInfo;
  24781. /** @hidden */
  24782. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24783. /**
  24784. * Gets total number of vertices
  24785. * @returns the total number of vertices
  24786. */
  24787. getTotalVertices(): number;
  24788. /**
  24789. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24790. * @param kind defines the data kind (Position, normal, etc...)
  24791. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24792. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24793. * @returns a float array containing vertex data
  24794. */
  24795. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24796. /**
  24797. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24798. * @param kind defines the data kind (Position, normal, etc...)
  24799. * @returns true if the vertex buffer with the specified kind is updatable
  24800. */
  24801. isVertexBufferUpdatable(kind: string): boolean;
  24802. /**
  24803. * Gets a specific vertex buffer
  24804. * @param kind defines the data kind (Position, normal, etc...)
  24805. * @returns a VertexBuffer
  24806. */
  24807. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24808. /**
  24809. * Returns all vertex buffers
  24810. * @return an object holding all vertex buffers indexed by kind
  24811. */
  24812. getVertexBuffers(): Nullable<{
  24813. [key: string]: VertexBuffer;
  24814. }>;
  24815. /**
  24816. * Gets a boolean indicating if specific vertex buffer is present
  24817. * @param kind defines the data kind (Position, normal, etc...)
  24818. * @returns true if data is present
  24819. */
  24820. isVerticesDataPresent(kind: string): boolean;
  24821. /**
  24822. * Gets a list of all attached data kinds (Position, normal, etc...)
  24823. * @returns a list of string containing all kinds
  24824. */
  24825. getVerticesDataKinds(): string[];
  24826. /**
  24827. * Update index buffer
  24828. * @param indices defines the indices to store in the index buffer
  24829. * @param offset defines the offset in the target buffer where to store the data
  24830. * @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)
  24831. */
  24832. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24833. /**
  24834. * Creates a new index buffer
  24835. * @param indices defines the indices to store in the index buffer
  24836. * @param totalVertices defines the total number of vertices (could be null)
  24837. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24838. */
  24839. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24840. /**
  24841. * Return the total number of indices
  24842. * @returns the total number of indices
  24843. */
  24844. getTotalIndices(): number;
  24845. /**
  24846. * Gets the index buffer array
  24847. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24848. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24849. * @returns the index buffer array
  24850. */
  24851. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24852. /**
  24853. * Gets the index buffer
  24854. * @return the index buffer
  24855. */
  24856. getIndexBuffer(): Nullable<DataBuffer>;
  24857. /** @hidden */
  24858. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24859. /**
  24860. * Release the associated resources for a specific mesh
  24861. * @param mesh defines the source mesh
  24862. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24863. */
  24864. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24865. /**
  24866. * Apply current geometry to a given mesh
  24867. * @param mesh defines the mesh to apply geometry to
  24868. */
  24869. applyToMesh(mesh: Mesh): void;
  24870. private _updateExtend;
  24871. private _applyToMesh;
  24872. private notifyUpdate;
  24873. /**
  24874. * Load the geometry if it was flagged as delay loaded
  24875. * @param scene defines the hosting scene
  24876. * @param onLoaded defines a callback called when the geometry is loaded
  24877. */
  24878. load(scene: Scene, onLoaded?: () => void): void;
  24879. private _queueLoad;
  24880. /**
  24881. * Invert the geometry to move from a right handed system to a left handed one.
  24882. */
  24883. toLeftHanded(): void;
  24884. /** @hidden */
  24885. _resetPointsArrayCache(): void;
  24886. /** @hidden */
  24887. _generatePointsArray(): boolean;
  24888. /**
  24889. * Gets a value indicating if the geometry is disposed
  24890. * @returns true if the geometry was disposed
  24891. */
  24892. isDisposed(): boolean;
  24893. private _disposeVertexArrayObjects;
  24894. /**
  24895. * Free all associated resources
  24896. */
  24897. dispose(): void;
  24898. /**
  24899. * Clone the current geometry into a new geometry
  24900. * @param id defines the unique ID of the new geometry
  24901. * @returns a new geometry object
  24902. */
  24903. copy(id: string): Geometry;
  24904. /**
  24905. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24906. * @return a JSON representation of the current geometry data (without the vertices data)
  24907. */
  24908. serialize(): any;
  24909. private toNumberArray;
  24910. /**
  24911. * Serialize all vertices data into a JSON oject
  24912. * @returns a JSON representation of the current geometry data
  24913. */
  24914. serializeVerticeData(): any;
  24915. /**
  24916. * Extracts a clone of a mesh geometry
  24917. * @param mesh defines the source mesh
  24918. * @param id defines the unique ID of the new geometry object
  24919. * @returns the new geometry object
  24920. */
  24921. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24922. /**
  24923. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24924. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24925. * Be aware Math.random() could cause collisions, but:
  24926. * "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"
  24927. * @returns a string containing a new GUID
  24928. */
  24929. static RandomId(): string;
  24930. /** @hidden */
  24931. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24932. private static _CleanMatricesWeights;
  24933. /**
  24934. * Create a new geometry from persisted data (Using .babylon file format)
  24935. * @param parsedVertexData defines the persisted data
  24936. * @param scene defines the hosting scene
  24937. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24938. * @returns the new geometry object
  24939. */
  24940. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24941. }
  24942. }
  24943. declare module BABYLON {
  24944. /**
  24945. * Define an interface for all classes that will get and set the data on vertices
  24946. */
  24947. export interface IGetSetVerticesData {
  24948. /**
  24949. * Gets a boolean indicating if specific vertex data is present
  24950. * @param kind defines the vertex data kind to use
  24951. * @returns true is data kind is present
  24952. */
  24953. isVerticesDataPresent(kind: string): boolean;
  24954. /**
  24955. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24956. * @param kind defines the data kind (Position, normal, etc...)
  24957. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24958. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24959. * @returns a float array containing vertex data
  24960. */
  24961. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24962. /**
  24963. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24964. * @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.
  24965. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24966. * @returns the indices array or an empty array if the mesh has no geometry
  24967. */
  24968. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24969. /**
  24970. * Set specific vertex data
  24971. * @param kind defines the data kind (Position, normal, etc...)
  24972. * @param data defines the vertex data to use
  24973. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24974. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24975. */
  24976. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24977. /**
  24978. * Update a specific associated vertex buffer
  24979. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24980. * - VertexBuffer.PositionKind
  24981. * - VertexBuffer.UVKind
  24982. * - VertexBuffer.UV2Kind
  24983. * - VertexBuffer.UV3Kind
  24984. * - VertexBuffer.UV4Kind
  24985. * - VertexBuffer.UV5Kind
  24986. * - VertexBuffer.UV6Kind
  24987. * - VertexBuffer.ColorKind
  24988. * - VertexBuffer.MatricesIndicesKind
  24989. * - VertexBuffer.MatricesIndicesExtraKind
  24990. * - VertexBuffer.MatricesWeightsKind
  24991. * - VertexBuffer.MatricesWeightsExtraKind
  24992. * @param data defines the data source
  24993. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24994. * @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)
  24995. */
  24996. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24997. /**
  24998. * Creates a new index buffer
  24999. * @param indices defines the indices to store in the index buffer
  25000. * @param totalVertices defines the total number of vertices (could be null)
  25001. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25002. */
  25003. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25004. }
  25005. /**
  25006. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25007. */
  25008. export class VertexData {
  25009. /**
  25010. * Mesh side orientation : usually the external or front surface
  25011. */
  25012. static readonly FRONTSIDE: number;
  25013. /**
  25014. * Mesh side orientation : usually the internal or back surface
  25015. */
  25016. static readonly BACKSIDE: number;
  25017. /**
  25018. * Mesh side orientation : both internal and external or front and back surfaces
  25019. */
  25020. static readonly DOUBLESIDE: number;
  25021. /**
  25022. * Mesh side orientation : by default, `FRONTSIDE`
  25023. */
  25024. static readonly DEFAULTSIDE: number;
  25025. /**
  25026. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25027. */
  25028. positions: Nullable<FloatArray>;
  25029. /**
  25030. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25031. */
  25032. normals: Nullable<FloatArray>;
  25033. /**
  25034. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25035. */
  25036. tangents: Nullable<FloatArray>;
  25037. /**
  25038. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25039. */
  25040. uvs: Nullable<FloatArray>;
  25041. /**
  25042. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25043. */
  25044. uvs2: Nullable<FloatArray>;
  25045. /**
  25046. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25047. */
  25048. uvs3: Nullable<FloatArray>;
  25049. /**
  25050. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25051. */
  25052. uvs4: Nullable<FloatArray>;
  25053. /**
  25054. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25055. */
  25056. uvs5: Nullable<FloatArray>;
  25057. /**
  25058. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25059. */
  25060. uvs6: Nullable<FloatArray>;
  25061. /**
  25062. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25063. */
  25064. colors: Nullable<FloatArray>;
  25065. /**
  25066. * 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).
  25067. */
  25068. matricesIndices: Nullable<FloatArray>;
  25069. /**
  25070. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25071. */
  25072. matricesWeights: Nullable<FloatArray>;
  25073. /**
  25074. * An array extending the number of possible indices
  25075. */
  25076. matricesIndicesExtra: Nullable<FloatArray>;
  25077. /**
  25078. * An array extending the number of possible weights when the number of indices is extended
  25079. */
  25080. matricesWeightsExtra: Nullable<FloatArray>;
  25081. /**
  25082. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25083. */
  25084. indices: Nullable<IndicesArray>;
  25085. /**
  25086. * Uses the passed data array to set the set the values for the specified kind of data
  25087. * @param data a linear array of floating numbers
  25088. * @param kind the type of data that is being set, eg positions, colors etc
  25089. */
  25090. set(data: FloatArray, kind: string): void;
  25091. /**
  25092. * Associates the vertexData to the passed Mesh.
  25093. * Sets it as updatable or not (default `false`)
  25094. * @param mesh the mesh the vertexData is applied to
  25095. * @param updatable when used and having the value true allows new data to update the vertexData
  25096. * @returns the VertexData
  25097. */
  25098. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25099. /**
  25100. * Associates the vertexData to the passed Geometry.
  25101. * Sets it as updatable or not (default `false`)
  25102. * @param geometry the geometry the vertexData is applied to
  25103. * @param updatable when used and having the value true allows new data to update the vertexData
  25104. * @returns VertexData
  25105. */
  25106. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25107. /**
  25108. * Updates the associated mesh
  25109. * @param mesh the mesh to be updated
  25110. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25111. * @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
  25112. * @returns VertexData
  25113. */
  25114. updateMesh(mesh: Mesh): VertexData;
  25115. /**
  25116. * Updates the associated geometry
  25117. * @param geometry the geometry to be updated
  25118. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25119. * @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
  25120. * @returns VertexData.
  25121. */
  25122. updateGeometry(geometry: Geometry): VertexData;
  25123. private _applyTo;
  25124. private _update;
  25125. /**
  25126. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25127. * @param matrix the transforming matrix
  25128. * @returns the VertexData
  25129. */
  25130. transform(matrix: Matrix): VertexData;
  25131. /**
  25132. * Merges the passed VertexData into the current one
  25133. * @param other the VertexData to be merged into the current one
  25134. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25135. * @returns the modified VertexData
  25136. */
  25137. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25138. private _mergeElement;
  25139. private _validate;
  25140. /**
  25141. * Serializes the VertexData
  25142. * @returns a serialized object
  25143. */
  25144. serialize(): any;
  25145. /**
  25146. * Extracts the vertexData from a mesh
  25147. * @param mesh the mesh from which to extract the VertexData
  25148. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25149. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25150. * @returns the object VertexData associated to the passed mesh
  25151. */
  25152. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25153. /**
  25154. * Extracts the vertexData from the geometry
  25155. * @param geometry the geometry from which to extract the VertexData
  25156. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25157. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25158. * @returns the object VertexData associated to the passed mesh
  25159. */
  25160. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25161. private static _ExtractFrom;
  25162. /**
  25163. * Creates the VertexData for a Ribbon
  25164. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25165. * * pathArray array of paths, each of which an array of successive Vector3
  25166. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25167. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25168. * * 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
  25169. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25170. * * 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)
  25171. * * 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)
  25172. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25173. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25174. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25175. * @returns the VertexData of the ribbon
  25176. */
  25177. static CreateRibbon(options: {
  25178. pathArray: Vector3[][];
  25179. closeArray?: boolean;
  25180. closePath?: boolean;
  25181. offset?: number;
  25182. sideOrientation?: number;
  25183. frontUVs?: Vector4;
  25184. backUVs?: Vector4;
  25185. invertUV?: boolean;
  25186. uvs?: Vector2[];
  25187. colors?: Color4[];
  25188. }): VertexData;
  25189. /**
  25190. * Creates the VertexData for a box
  25191. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25192. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25193. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25194. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25195. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25196. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25197. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25198. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25199. * * 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)
  25200. * * 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)
  25201. * @returns the VertexData of the box
  25202. */
  25203. static CreateBox(options: {
  25204. size?: number;
  25205. width?: number;
  25206. height?: number;
  25207. depth?: number;
  25208. faceUV?: Vector4[];
  25209. faceColors?: Color4[];
  25210. sideOrientation?: number;
  25211. frontUVs?: Vector4;
  25212. backUVs?: Vector4;
  25213. }): VertexData;
  25214. /**
  25215. * Creates the VertexData for a tiled box
  25216. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25217. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25218. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25219. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25221. * @returns the VertexData of the box
  25222. */
  25223. static CreateTiledBox(options: {
  25224. pattern?: number;
  25225. width?: number;
  25226. height?: number;
  25227. depth?: number;
  25228. tileSize?: number;
  25229. tileWidth?: number;
  25230. tileHeight?: number;
  25231. alignHorizontal?: number;
  25232. alignVertical?: number;
  25233. faceUV?: Vector4[];
  25234. faceColors?: Color4[];
  25235. sideOrientation?: number;
  25236. }): VertexData;
  25237. /**
  25238. * Creates the VertexData for a tiled plane
  25239. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25240. * * pattern a limited pattern arrangement depending on the number
  25241. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25242. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25243. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25245. * * 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)
  25246. * * 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)
  25247. * @returns the VertexData of the tiled plane
  25248. */
  25249. static CreateTiledPlane(options: {
  25250. pattern?: number;
  25251. tileSize?: number;
  25252. tileWidth?: number;
  25253. tileHeight?: number;
  25254. size?: number;
  25255. width?: number;
  25256. height?: number;
  25257. alignHorizontal?: number;
  25258. alignVertical?: number;
  25259. sideOrientation?: number;
  25260. frontUVs?: Vector4;
  25261. backUVs?: Vector4;
  25262. }): VertexData;
  25263. /**
  25264. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25265. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25266. * * segments sets the number of horizontal strips optional, default 32
  25267. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25268. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25269. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25270. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25271. * * 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
  25272. * * 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
  25273. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25274. * * 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)
  25275. * * 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)
  25276. * @returns the VertexData of the ellipsoid
  25277. */
  25278. static CreateSphere(options: {
  25279. segments?: number;
  25280. diameter?: number;
  25281. diameterX?: number;
  25282. diameterY?: number;
  25283. diameterZ?: number;
  25284. arc?: number;
  25285. slice?: number;
  25286. sideOrientation?: number;
  25287. frontUVs?: Vector4;
  25288. backUVs?: Vector4;
  25289. }): VertexData;
  25290. /**
  25291. * Creates the VertexData for a cylinder, cone or prism
  25292. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25293. * * height sets the height (y direction) of the cylinder, optional, default 2
  25294. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25295. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25296. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25297. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25298. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25299. * * 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
  25300. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25301. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25302. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25303. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25304. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25305. * * 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)
  25306. * * 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)
  25307. * @returns the VertexData of the cylinder, cone or prism
  25308. */
  25309. static CreateCylinder(options: {
  25310. height?: number;
  25311. diameterTop?: number;
  25312. diameterBottom?: number;
  25313. diameter?: number;
  25314. tessellation?: number;
  25315. subdivisions?: number;
  25316. arc?: number;
  25317. faceColors?: Color4[];
  25318. faceUV?: Vector4[];
  25319. hasRings?: boolean;
  25320. enclose?: boolean;
  25321. sideOrientation?: number;
  25322. frontUVs?: Vector4;
  25323. backUVs?: Vector4;
  25324. }): VertexData;
  25325. /**
  25326. * Creates the VertexData for a torus
  25327. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25328. * * diameter the diameter of the torus, optional default 1
  25329. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25330. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25331. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25332. * * 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)
  25333. * * 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)
  25334. * @returns the VertexData of the torus
  25335. */
  25336. static CreateTorus(options: {
  25337. diameter?: number;
  25338. thickness?: number;
  25339. tessellation?: number;
  25340. sideOrientation?: number;
  25341. frontUVs?: Vector4;
  25342. backUVs?: Vector4;
  25343. }): VertexData;
  25344. /**
  25345. * Creates the VertexData of the LineSystem
  25346. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25347. * - lines an array of lines, each line being an array of successive Vector3
  25348. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25349. * @returns the VertexData of the LineSystem
  25350. */
  25351. static CreateLineSystem(options: {
  25352. lines: Vector3[][];
  25353. colors?: Nullable<Color4[][]>;
  25354. }): VertexData;
  25355. /**
  25356. * Create the VertexData for a DashedLines
  25357. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25358. * - points an array successive Vector3
  25359. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25360. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25361. * - dashNb the intended total number of dashes, optional, default 200
  25362. * @returns the VertexData for the DashedLines
  25363. */
  25364. static CreateDashedLines(options: {
  25365. points: Vector3[];
  25366. dashSize?: number;
  25367. gapSize?: number;
  25368. dashNb?: number;
  25369. }): VertexData;
  25370. /**
  25371. * Creates the VertexData for a Ground
  25372. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25373. * - width the width (x direction) of the ground, optional, default 1
  25374. * - height the height (z direction) of the ground, optional, default 1
  25375. * - subdivisions the number of subdivisions per side, optional, default 1
  25376. * @returns the VertexData of the Ground
  25377. */
  25378. static CreateGround(options: {
  25379. width?: number;
  25380. height?: number;
  25381. subdivisions?: number;
  25382. subdivisionsX?: number;
  25383. subdivisionsY?: number;
  25384. }): VertexData;
  25385. /**
  25386. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25387. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25388. * * xmin the ground minimum X coordinate, optional, default -1
  25389. * * zmin the ground minimum Z coordinate, optional, default -1
  25390. * * xmax the ground maximum X coordinate, optional, default 1
  25391. * * zmax the ground maximum Z coordinate, optional, default 1
  25392. * * 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}
  25393. * * 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}
  25394. * @returns the VertexData of the TiledGround
  25395. */
  25396. static CreateTiledGround(options: {
  25397. xmin: number;
  25398. zmin: number;
  25399. xmax: number;
  25400. zmax: number;
  25401. subdivisions?: {
  25402. w: number;
  25403. h: number;
  25404. };
  25405. precision?: {
  25406. w: number;
  25407. h: number;
  25408. };
  25409. }): VertexData;
  25410. /**
  25411. * Creates the VertexData of the Ground designed from a heightmap
  25412. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25413. * * width the width (x direction) of the ground
  25414. * * height the height (z direction) of the ground
  25415. * * subdivisions the number of subdivisions per side
  25416. * * minHeight the minimum altitude on the ground, optional, default 0
  25417. * * maxHeight the maximum altitude on the ground, optional default 1
  25418. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25419. * * buffer the array holding the image color data
  25420. * * bufferWidth the width of image
  25421. * * bufferHeight the height of image
  25422. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25423. * @returns the VertexData of the Ground designed from a heightmap
  25424. */
  25425. static CreateGroundFromHeightMap(options: {
  25426. width: number;
  25427. height: number;
  25428. subdivisions: number;
  25429. minHeight: number;
  25430. maxHeight: number;
  25431. colorFilter: Color3;
  25432. buffer: Uint8Array;
  25433. bufferWidth: number;
  25434. bufferHeight: number;
  25435. alphaFilter: number;
  25436. }): VertexData;
  25437. /**
  25438. * Creates the VertexData for a Plane
  25439. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25440. * * size sets the width and height of the plane to the value of size, optional default 1
  25441. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25442. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25443. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25444. * * 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)
  25445. * * 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)
  25446. * @returns the VertexData of the box
  25447. */
  25448. static CreatePlane(options: {
  25449. size?: number;
  25450. width?: number;
  25451. height?: number;
  25452. sideOrientation?: number;
  25453. frontUVs?: Vector4;
  25454. backUVs?: Vector4;
  25455. }): VertexData;
  25456. /**
  25457. * Creates the VertexData of the Disc or regular Polygon
  25458. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25459. * * radius the radius of the disc, optional default 0.5
  25460. * * tessellation the number of polygon sides, optional, default 64
  25461. * * 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
  25462. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25463. * * 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)
  25464. * * 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)
  25465. * @returns the VertexData of the box
  25466. */
  25467. static CreateDisc(options: {
  25468. radius?: number;
  25469. tessellation?: number;
  25470. arc?: number;
  25471. sideOrientation?: number;
  25472. frontUVs?: Vector4;
  25473. backUVs?: Vector4;
  25474. }): VertexData;
  25475. /**
  25476. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25477. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25478. * @param polygon a mesh built from polygonTriangulation.build()
  25479. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25480. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25481. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25482. * @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)
  25483. * @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)
  25484. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25485. * @returns the VertexData of the Polygon
  25486. */
  25487. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25488. /**
  25489. * Creates the VertexData of the IcoSphere
  25490. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25491. * * radius the radius of the IcoSphere, optional default 1
  25492. * * radiusX allows stretching in the x direction, optional, default radius
  25493. * * radiusY allows stretching in the y direction, optional, default radius
  25494. * * radiusZ allows stretching in the z direction, optional, default radius
  25495. * * flat when true creates a flat shaded mesh, optional, default true
  25496. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25498. * * 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)
  25499. * * 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)
  25500. * @returns the VertexData of the IcoSphere
  25501. */
  25502. static CreateIcoSphere(options: {
  25503. radius?: number;
  25504. radiusX?: number;
  25505. radiusY?: number;
  25506. radiusZ?: number;
  25507. flat?: boolean;
  25508. subdivisions?: number;
  25509. sideOrientation?: number;
  25510. frontUVs?: Vector4;
  25511. backUVs?: Vector4;
  25512. }): VertexData;
  25513. /**
  25514. * Creates the VertexData for a Polyhedron
  25515. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25516. * * type provided types are:
  25517. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25518. * * 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)
  25519. * * size the size of the IcoSphere, optional default 1
  25520. * * sizeX allows stretching in the x direction, optional, default size
  25521. * * sizeY allows stretching in the y direction, optional, default size
  25522. * * sizeZ allows stretching in the z direction, optional, default size
  25523. * * 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
  25524. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25525. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25526. * * flat when true creates a flat shaded mesh, optional, default true
  25527. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25528. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25529. * * 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)
  25530. * * 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)
  25531. * @returns the VertexData of the Polyhedron
  25532. */
  25533. static CreatePolyhedron(options: {
  25534. type?: number;
  25535. size?: number;
  25536. sizeX?: number;
  25537. sizeY?: number;
  25538. sizeZ?: number;
  25539. custom?: any;
  25540. faceUV?: Vector4[];
  25541. faceColors?: Color4[];
  25542. flat?: boolean;
  25543. sideOrientation?: number;
  25544. frontUVs?: Vector4;
  25545. backUVs?: Vector4;
  25546. }): VertexData;
  25547. /**
  25548. * Creates the VertexData for a TorusKnot
  25549. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25550. * * radius the radius of the torus knot, optional, default 2
  25551. * * tube the thickness of the tube, optional, default 0.5
  25552. * * radialSegments the number of sides on each tube segments, optional, default 32
  25553. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25554. * * p the number of windings around the z axis, optional, default 2
  25555. * * q the number of windings around the x axis, optional, default 3
  25556. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25557. * * 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)
  25558. * * 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)
  25559. * @returns the VertexData of the Torus Knot
  25560. */
  25561. static CreateTorusKnot(options: {
  25562. radius?: number;
  25563. tube?: number;
  25564. radialSegments?: number;
  25565. tubularSegments?: number;
  25566. p?: number;
  25567. q?: number;
  25568. sideOrientation?: number;
  25569. frontUVs?: Vector4;
  25570. backUVs?: Vector4;
  25571. }): VertexData;
  25572. /**
  25573. * Compute normals for given positions and indices
  25574. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25575. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25576. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25577. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25578. * * facetNormals : optional array of facet normals (vector3)
  25579. * * facetPositions : optional array of facet positions (vector3)
  25580. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25581. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25582. * * bInfo : optional bounding info, required for facetPartitioning computation
  25583. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25584. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25585. * * useRightHandedSystem: optional boolean to for right handed system computation
  25586. * * depthSort : optional boolean to enable the facet depth sort computation
  25587. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25588. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25589. */
  25590. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25591. facetNormals?: any;
  25592. facetPositions?: any;
  25593. facetPartitioning?: any;
  25594. ratio?: number;
  25595. bInfo?: any;
  25596. bbSize?: Vector3;
  25597. subDiv?: any;
  25598. useRightHandedSystem?: boolean;
  25599. depthSort?: boolean;
  25600. distanceTo?: Vector3;
  25601. depthSortedFacets?: any;
  25602. }): void;
  25603. /** @hidden */
  25604. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25605. /**
  25606. * Applies VertexData created from the imported parameters to the geometry
  25607. * @param parsedVertexData the parsed data from an imported file
  25608. * @param geometry the geometry to apply the VertexData to
  25609. */
  25610. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25611. }
  25612. }
  25613. declare module BABYLON {
  25614. /**
  25615. * Defines a target to use with MorphTargetManager
  25616. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25617. */
  25618. export class MorphTarget implements IAnimatable {
  25619. /** defines the name of the target */
  25620. name: string;
  25621. /**
  25622. * Gets or sets the list of animations
  25623. */
  25624. animations: Animation[];
  25625. private _scene;
  25626. private _positions;
  25627. private _normals;
  25628. private _tangents;
  25629. private _uvs;
  25630. private _influence;
  25631. private _uniqueId;
  25632. /**
  25633. * Observable raised when the influence changes
  25634. */
  25635. onInfluenceChanged: Observable<boolean>;
  25636. /** @hidden */
  25637. _onDataLayoutChanged: Observable<void>;
  25638. /**
  25639. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25640. */
  25641. get influence(): number;
  25642. set influence(influence: number);
  25643. /**
  25644. * Gets or sets the id of the morph Target
  25645. */
  25646. id: string;
  25647. private _animationPropertiesOverride;
  25648. /**
  25649. * Gets or sets the animation properties override
  25650. */
  25651. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25652. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25653. /**
  25654. * Creates a new MorphTarget
  25655. * @param name defines the name of the target
  25656. * @param influence defines the influence to use
  25657. * @param scene defines the scene the morphtarget belongs to
  25658. */
  25659. constructor(
  25660. /** defines the name of the target */
  25661. name: string, influence?: number, scene?: Nullable<Scene>);
  25662. /**
  25663. * Gets the unique ID of this manager
  25664. */
  25665. get uniqueId(): number;
  25666. /**
  25667. * Gets a boolean defining if the target contains position data
  25668. */
  25669. get hasPositions(): boolean;
  25670. /**
  25671. * Gets a boolean defining if the target contains normal data
  25672. */
  25673. get hasNormals(): boolean;
  25674. /**
  25675. * Gets a boolean defining if the target contains tangent data
  25676. */
  25677. get hasTangents(): boolean;
  25678. /**
  25679. * Gets a boolean defining if the target contains texture coordinates data
  25680. */
  25681. get hasUVs(): boolean;
  25682. /**
  25683. * Affects position data to this target
  25684. * @param data defines the position data to use
  25685. */
  25686. setPositions(data: Nullable<FloatArray>): void;
  25687. /**
  25688. * Gets the position data stored in this target
  25689. * @returns a FloatArray containing the position data (or null if not present)
  25690. */
  25691. getPositions(): Nullable<FloatArray>;
  25692. /**
  25693. * Affects normal data to this target
  25694. * @param data defines the normal data to use
  25695. */
  25696. setNormals(data: Nullable<FloatArray>): void;
  25697. /**
  25698. * Gets the normal data stored in this target
  25699. * @returns a FloatArray containing the normal data (or null if not present)
  25700. */
  25701. getNormals(): Nullable<FloatArray>;
  25702. /**
  25703. * Affects tangent data to this target
  25704. * @param data defines the tangent data to use
  25705. */
  25706. setTangents(data: Nullable<FloatArray>): void;
  25707. /**
  25708. * Gets the tangent data stored in this target
  25709. * @returns a FloatArray containing the tangent data (or null if not present)
  25710. */
  25711. getTangents(): Nullable<FloatArray>;
  25712. /**
  25713. * Affects texture coordinates data to this target
  25714. * @param data defines the texture coordinates data to use
  25715. */
  25716. setUVs(data: Nullable<FloatArray>): void;
  25717. /**
  25718. * Gets the texture coordinates data stored in this target
  25719. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25720. */
  25721. getUVs(): Nullable<FloatArray>;
  25722. /**
  25723. * Clone the current target
  25724. * @returns a new MorphTarget
  25725. */
  25726. clone(): MorphTarget;
  25727. /**
  25728. * Serializes the current target into a Serialization object
  25729. * @returns the serialized object
  25730. */
  25731. serialize(): any;
  25732. /**
  25733. * Returns the string "MorphTarget"
  25734. * @returns "MorphTarget"
  25735. */
  25736. getClassName(): string;
  25737. /**
  25738. * Creates a new target from serialized data
  25739. * @param serializationObject defines the serialized data to use
  25740. * @returns a new MorphTarget
  25741. */
  25742. static Parse(serializationObject: any): MorphTarget;
  25743. /**
  25744. * Creates a MorphTarget from mesh data
  25745. * @param mesh defines the source mesh
  25746. * @param name defines the name to use for the new target
  25747. * @param influence defines the influence to attach to the target
  25748. * @returns a new MorphTarget
  25749. */
  25750. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25751. }
  25752. }
  25753. declare module BABYLON {
  25754. /**
  25755. * This class is used to deform meshes using morphing between different targets
  25756. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25757. */
  25758. export class MorphTargetManager {
  25759. private _targets;
  25760. private _targetInfluenceChangedObservers;
  25761. private _targetDataLayoutChangedObservers;
  25762. private _activeTargets;
  25763. private _scene;
  25764. private _influences;
  25765. private _supportsNormals;
  25766. private _supportsTangents;
  25767. private _supportsUVs;
  25768. private _vertexCount;
  25769. private _uniqueId;
  25770. private _tempInfluences;
  25771. /**
  25772. * Gets or sets a boolean indicating if normals must be morphed
  25773. */
  25774. enableNormalMorphing: boolean;
  25775. /**
  25776. * Gets or sets a boolean indicating if tangents must be morphed
  25777. */
  25778. enableTangentMorphing: boolean;
  25779. /**
  25780. * Gets or sets a boolean indicating if UV must be morphed
  25781. */
  25782. enableUVMorphing: boolean;
  25783. /**
  25784. * Creates a new MorphTargetManager
  25785. * @param scene defines the current scene
  25786. */
  25787. constructor(scene?: Nullable<Scene>);
  25788. /**
  25789. * Gets the unique ID of this manager
  25790. */
  25791. get uniqueId(): number;
  25792. /**
  25793. * Gets the number of vertices handled by this manager
  25794. */
  25795. get vertexCount(): number;
  25796. /**
  25797. * Gets a boolean indicating if this manager supports morphing of normals
  25798. */
  25799. get supportsNormals(): boolean;
  25800. /**
  25801. * Gets a boolean indicating if this manager supports morphing of tangents
  25802. */
  25803. get supportsTangents(): boolean;
  25804. /**
  25805. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25806. */
  25807. get supportsUVs(): boolean;
  25808. /**
  25809. * Gets the number of targets stored in this manager
  25810. */
  25811. get numTargets(): number;
  25812. /**
  25813. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25814. */
  25815. get numInfluencers(): number;
  25816. /**
  25817. * Gets the list of influences (one per target)
  25818. */
  25819. get influences(): Float32Array;
  25820. /**
  25821. * Gets the active target at specified index. An active target is a target with an influence > 0
  25822. * @param index defines the index to check
  25823. * @returns the requested target
  25824. */
  25825. getActiveTarget(index: number): MorphTarget;
  25826. /**
  25827. * Gets the target at specified index
  25828. * @param index defines the index to check
  25829. * @returns the requested target
  25830. */
  25831. getTarget(index: number): MorphTarget;
  25832. /**
  25833. * Add a new target to this manager
  25834. * @param target defines the target to add
  25835. */
  25836. addTarget(target: MorphTarget): void;
  25837. /**
  25838. * Removes a target from the manager
  25839. * @param target defines the target to remove
  25840. */
  25841. removeTarget(target: MorphTarget): void;
  25842. /**
  25843. * Clone the current manager
  25844. * @returns a new MorphTargetManager
  25845. */
  25846. clone(): MorphTargetManager;
  25847. /**
  25848. * Serializes the current manager into a Serialization object
  25849. * @returns the serialized object
  25850. */
  25851. serialize(): any;
  25852. private _syncActiveTargets;
  25853. /**
  25854. * Syncrhonize the targets with all the meshes using this morph target manager
  25855. */
  25856. synchronize(): void;
  25857. /**
  25858. * Creates a new MorphTargetManager from serialized data
  25859. * @param serializationObject defines the serialized data
  25860. * @param scene defines the hosting scene
  25861. * @returns the new MorphTargetManager
  25862. */
  25863. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25864. }
  25865. }
  25866. declare module BABYLON {
  25867. /**
  25868. * Class used to represent a specific level of detail of a mesh
  25869. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25870. */
  25871. export class MeshLODLevel {
  25872. /** Defines the distance where this level should start being displayed */
  25873. distance: number;
  25874. /** Defines the mesh to use to render this level */
  25875. mesh: Nullable<Mesh>;
  25876. /**
  25877. * Creates a new LOD level
  25878. * @param distance defines the distance where this level should star being displayed
  25879. * @param mesh defines the mesh to use to render this level
  25880. */
  25881. constructor(
  25882. /** Defines the distance where this level should start being displayed */
  25883. distance: number,
  25884. /** Defines the mesh to use to render this level */
  25885. mesh: Nullable<Mesh>);
  25886. }
  25887. }
  25888. declare module BABYLON {
  25889. /**
  25890. * Mesh representing the gorund
  25891. */
  25892. export class GroundMesh extends Mesh {
  25893. /** If octree should be generated */
  25894. generateOctree: boolean;
  25895. private _heightQuads;
  25896. /** @hidden */
  25897. _subdivisionsX: number;
  25898. /** @hidden */
  25899. _subdivisionsY: number;
  25900. /** @hidden */
  25901. _width: number;
  25902. /** @hidden */
  25903. _height: number;
  25904. /** @hidden */
  25905. _minX: number;
  25906. /** @hidden */
  25907. _maxX: number;
  25908. /** @hidden */
  25909. _minZ: number;
  25910. /** @hidden */
  25911. _maxZ: number;
  25912. constructor(name: string, scene: Scene);
  25913. /**
  25914. * "GroundMesh"
  25915. * @returns "GroundMesh"
  25916. */
  25917. getClassName(): string;
  25918. /**
  25919. * The minimum of x and y subdivisions
  25920. */
  25921. get subdivisions(): number;
  25922. /**
  25923. * X subdivisions
  25924. */
  25925. get subdivisionsX(): number;
  25926. /**
  25927. * Y subdivisions
  25928. */
  25929. get subdivisionsY(): number;
  25930. /**
  25931. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25932. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25933. * @param chunksCount the number of subdivisions for x and y
  25934. * @param octreeBlocksSize (Default: 32)
  25935. */
  25936. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25937. /**
  25938. * Returns a height (y) value in the Worl system :
  25939. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25940. * @param x x coordinate
  25941. * @param z z coordinate
  25942. * @returns the ground y position if (x, z) are outside the ground surface.
  25943. */
  25944. getHeightAtCoordinates(x: number, z: number): number;
  25945. /**
  25946. * Returns a normalized vector (Vector3) orthogonal to the ground
  25947. * at the ground coordinates (x, z) expressed in the World system.
  25948. * @param x x coordinate
  25949. * @param z z coordinate
  25950. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25951. */
  25952. getNormalAtCoordinates(x: number, z: number): Vector3;
  25953. /**
  25954. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25955. * at the ground coordinates (x, z) expressed in the World system.
  25956. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25957. * @param x x coordinate
  25958. * @param z z coordinate
  25959. * @param ref vector to store the result
  25960. * @returns the GroundMesh.
  25961. */
  25962. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25963. /**
  25964. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25965. * if the ground has been updated.
  25966. * This can be used in the render loop.
  25967. * @returns the GroundMesh.
  25968. */
  25969. updateCoordinateHeights(): GroundMesh;
  25970. private _getFacetAt;
  25971. private _initHeightQuads;
  25972. private _computeHeightQuads;
  25973. /**
  25974. * Serializes this ground mesh
  25975. * @param serializationObject object to write serialization to
  25976. */
  25977. serialize(serializationObject: any): void;
  25978. /**
  25979. * Parses a serialized ground mesh
  25980. * @param parsedMesh the serialized mesh
  25981. * @param scene the scene to create the ground mesh in
  25982. * @returns the created ground mesh
  25983. */
  25984. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  25985. }
  25986. }
  25987. declare module BABYLON {
  25988. /**
  25989. * Interface for Physics-Joint data
  25990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  25991. */
  25992. export interface PhysicsJointData {
  25993. /**
  25994. * The main pivot of the joint
  25995. */
  25996. mainPivot?: Vector3;
  25997. /**
  25998. * The connected pivot of the joint
  25999. */
  26000. connectedPivot?: Vector3;
  26001. /**
  26002. * The main axis of the joint
  26003. */
  26004. mainAxis?: Vector3;
  26005. /**
  26006. * The connected axis of the joint
  26007. */
  26008. connectedAxis?: Vector3;
  26009. /**
  26010. * The collision of the joint
  26011. */
  26012. collision?: boolean;
  26013. /**
  26014. * Native Oimo/Cannon/Energy data
  26015. */
  26016. nativeParams?: any;
  26017. }
  26018. /**
  26019. * This is a holder class for the physics joint created by the physics plugin
  26020. * It holds a set of functions to control the underlying joint
  26021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26022. */
  26023. export class PhysicsJoint {
  26024. /**
  26025. * The type of the physics joint
  26026. */
  26027. type: number;
  26028. /**
  26029. * The data for the physics joint
  26030. */
  26031. jointData: PhysicsJointData;
  26032. private _physicsJoint;
  26033. protected _physicsPlugin: IPhysicsEnginePlugin;
  26034. /**
  26035. * Initializes the physics joint
  26036. * @param type The type of the physics joint
  26037. * @param jointData The data for the physics joint
  26038. */
  26039. constructor(
  26040. /**
  26041. * The type of the physics joint
  26042. */
  26043. type: number,
  26044. /**
  26045. * The data for the physics joint
  26046. */
  26047. jointData: PhysicsJointData);
  26048. /**
  26049. * Gets the physics joint
  26050. */
  26051. get physicsJoint(): any;
  26052. /**
  26053. * Sets the physics joint
  26054. */
  26055. set physicsJoint(newJoint: any);
  26056. /**
  26057. * Sets the physics plugin
  26058. */
  26059. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26060. /**
  26061. * Execute a function that is physics-plugin specific.
  26062. * @param {Function} func the function that will be executed.
  26063. * It accepts two parameters: the physics world and the physics joint
  26064. */
  26065. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26066. /**
  26067. * Distance-Joint type
  26068. */
  26069. static DistanceJoint: number;
  26070. /**
  26071. * Hinge-Joint type
  26072. */
  26073. static HingeJoint: number;
  26074. /**
  26075. * Ball-and-Socket joint type
  26076. */
  26077. static BallAndSocketJoint: number;
  26078. /**
  26079. * Wheel-Joint type
  26080. */
  26081. static WheelJoint: number;
  26082. /**
  26083. * Slider-Joint type
  26084. */
  26085. static SliderJoint: number;
  26086. /**
  26087. * Prismatic-Joint type
  26088. */
  26089. static PrismaticJoint: number;
  26090. /**
  26091. * Universal-Joint type
  26092. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26093. */
  26094. static UniversalJoint: number;
  26095. /**
  26096. * Hinge-Joint 2 type
  26097. */
  26098. static Hinge2Joint: number;
  26099. /**
  26100. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26101. */
  26102. static PointToPointJoint: number;
  26103. /**
  26104. * Spring-Joint type
  26105. */
  26106. static SpringJoint: number;
  26107. /**
  26108. * Lock-Joint type
  26109. */
  26110. static LockJoint: number;
  26111. }
  26112. /**
  26113. * A class representing a physics distance joint
  26114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26115. */
  26116. export class DistanceJoint extends PhysicsJoint {
  26117. /**
  26118. *
  26119. * @param jointData The data for the Distance-Joint
  26120. */
  26121. constructor(jointData: DistanceJointData);
  26122. /**
  26123. * Update the predefined distance.
  26124. * @param maxDistance The maximum preferred distance
  26125. * @param minDistance The minimum preferred distance
  26126. */
  26127. updateDistance(maxDistance: number, minDistance?: number): void;
  26128. }
  26129. /**
  26130. * Represents a Motor-Enabled Joint
  26131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26132. */
  26133. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26134. /**
  26135. * Initializes the Motor-Enabled Joint
  26136. * @param type The type of the joint
  26137. * @param jointData The physica joint data for the joint
  26138. */
  26139. constructor(type: number, jointData: PhysicsJointData);
  26140. /**
  26141. * Set the motor values.
  26142. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26143. * @param force the force to apply
  26144. * @param maxForce max force for this motor.
  26145. */
  26146. setMotor(force?: number, maxForce?: number): void;
  26147. /**
  26148. * Set the motor's limits.
  26149. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26150. * @param upperLimit The upper limit of the motor
  26151. * @param lowerLimit The lower limit of the motor
  26152. */
  26153. setLimit(upperLimit: number, lowerLimit?: number): void;
  26154. }
  26155. /**
  26156. * This class represents a single physics Hinge-Joint
  26157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26158. */
  26159. export class HingeJoint extends MotorEnabledJoint {
  26160. /**
  26161. * Initializes the Hinge-Joint
  26162. * @param jointData The joint data for the Hinge-Joint
  26163. */
  26164. constructor(jointData: PhysicsJointData);
  26165. /**
  26166. * Set the motor values.
  26167. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26168. * @param {number} force the force to apply
  26169. * @param {number} maxForce max force for this motor.
  26170. */
  26171. setMotor(force?: number, maxForce?: number): void;
  26172. /**
  26173. * Set the motor's limits.
  26174. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26175. * @param upperLimit The upper limit of the motor
  26176. * @param lowerLimit The lower limit of the motor
  26177. */
  26178. setLimit(upperLimit: number, lowerLimit?: number): void;
  26179. }
  26180. /**
  26181. * This class represents a dual hinge physics joint (same as wheel joint)
  26182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26183. */
  26184. export class Hinge2Joint extends MotorEnabledJoint {
  26185. /**
  26186. * Initializes the Hinge2-Joint
  26187. * @param jointData The joint data for the Hinge2-Joint
  26188. */
  26189. constructor(jointData: PhysicsJointData);
  26190. /**
  26191. * Set the motor values.
  26192. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26193. * @param {number} targetSpeed the speed the motor is to reach
  26194. * @param {number} maxForce max force for this motor.
  26195. * @param {motorIndex} the motor's index, 0 or 1.
  26196. */
  26197. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26198. /**
  26199. * Set the motor limits.
  26200. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26201. * @param {number} upperLimit the upper limit
  26202. * @param {number} lowerLimit lower limit
  26203. * @param {motorIndex} the motor's index, 0 or 1.
  26204. */
  26205. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26206. }
  26207. /**
  26208. * Interface for a motor enabled joint
  26209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26210. */
  26211. export interface IMotorEnabledJoint {
  26212. /**
  26213. * Physics joint
  26214. */
  26215. physicsJoint: any;
  26216. /**
  26217. * Sets the motor of the motor-enabled joint
  26218. * @param force The force of the motor
  26219. * @param maxForce The maximum force of the motor
  26220. * @param motorIndex The index of the motor
  26221. */
  26222. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26223. /**
  26224. * Sets the limit of the motor
  26225. * @param upperLimit The upper limit of the motor
  26226. * @param lowerLimit The lower limit of the motor
  26227. * @param motorIndex The index of the motor
  26228. */
  26229. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26230. }
  26231. /**
  26232. * Joint data for a Distance-Joint
  26233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26234. */
  26235. export interface DistanceJointData extends PhysicsJointData {
  26236. /**
  26237. * Max distance the 2 joint objects can be apart
  26238. */
  26239. maxDistance: number;
  26240. }
  26241. /**
  26242. * Joint data from a spring joint
  26243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26244. */
  26245. export interface SpringJointData extends PhysicsJointData {
  26246. /**
  26247. * Length of the spring
  26248. */
  26249. length: number;
  26250. /**
  26251. * Stiffness of the spring
  26252. */
  26253. stiffness: number;
  26254. /**
  26255. * Damping of the spring
  26256. */
  26257. damping: number;
  26258. /** this callback will be called when applying the force to the impostors. */
  26259. forceApplicationCallback: () => void;
  26260. }
  26261. }
  26262. declare module BABYLON {
  26263. /**
  26264. * Holds the data for the raycast result
  26265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26266. */
  26267. export class PhysicsRaycastResult {
  26268. private _hasHit;
  26269. private _hitDistance;
  26270. private _hitNormalWorld;
  26271. private _hitPointWorld;
  26272. private _rayFromWorld;
  26273. private _rayToWorld;
  26274. /**
  26275. * Gets if there was a hit
  26276. */
  26277. get hasHit(): boolean;
  26278. /**
  26279. * Gets the distance from the hit
  26280. */
  26281. get hitDistance(): number;
  26282. /**
  26283. * Gets the hit normal/direction in the world
  26284. */
  26285. get hitNormalWorld(): Vector3;
  26286. /**
  26287. * Gets the hit point in the world
  26288. */
  26289. get hitPointWorld(): Vector3;
  26290. /**
  26291. * Gets the ray "start point" of the ray in the world
  26292. */
  26293. get rayFromWorld(): Vector3;
  26294. /**
  26295. * Gets the ray "end point" of the ray in the world
  26296. */
  26297. get rayToWorld(): Vector3;
  26298. /**
  26299. * Sets the hit data (normal & point in world space)
  26300. * @param hitNormalWorld defines the normal in world space
  26301. * @param hitPointWorld defines the point in world space
  26302. */
  26303. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26304. /**
  26305. * Sets the distance from the start point to the hit point
  26306. * @param distance
  26307. */
  26308. setHitDistance(distance: number): void;
  26309. /**
  26310. * Calculates the distance manually
  26311. */
  26312. calculateHitDistance(): void;
  26313. /**
  26314. * Resets all the values to default
  26315. * @param from The from point on world space
  26316. * @param to The to point on world space
  26317. */
  26318. reset(from?: Vector3, to?: Vector3): void;
  26319. }
  26320. /**
  26321. * Interface for the size containing width and height
  26322. */
  26323. interface IXYZ {
  26324. /**
  26325. * X
  26326. */
  26327. x: number;
  26328. /**
  26329. * Y
  26330. */
  26331. y: number;
  26332. /**
  26333. * Z
  26334. */
  26335. z: number;
  26336. }
  26337. }
  26338. declare module BABYLON {
  26339. /**
  26340. * Interface used to describe a physics joint
  26341. */
  26342. export interface PhysicsImpostorJoint {
  26343. /** Defines the main impostor to which the joint is linked */
  26344. mainImpostor: PhysicsImpostor;
  26345. /** Defines the impostor that is connected to the main impostor using this joint */
  26346. connectedImpostor: PhysicsImpostor;
  26347. /** Defines the joint itself */
  26348. joint: PhysicsJoint;
  26349. }
  26350. /** @hidden */
  26351. export interface IPhysicsEnginePlugin {
  26352. world: any;
  26353. name: string;
  26354. setGravity(gravity: Vector3): void;
  26355. setTimeStep(timeStep: number): void;
  26356. getTimeStep(): number;
  26357. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26358. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26359. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26360. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26361. removePhysicsBody(impostor: PhysicsImpostor): void;
  26362. generateJoint(joint: PhysicsImpostorJoint): void;
  26363. removeJoint(joint: PhysicsImpostorJoint): void;
  26364. isSupported(): boolean;
  26365. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26366. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26367. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26368. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26369. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26370. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26371. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26372. getBodyMass(impostor: PhysicsImpostor): number;
  26373. getBodyFriction(impostor: PhysicsImpostor): number;
  26374. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26375. getBodyRestitution(impostor: PhysicsImpostor): number;
  26376. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26377. getBodyPressure?(impostor: PhysicsImpostor): number;
  26378. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26379. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26380. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26381. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26382. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26383. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26384. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26385. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26386. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26387. sleepBody(impostor: PhysicsImpostor): void;
  26388. wakeUpBody(impostor: PhysicsImpostor): void;
  26389. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26390. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26391. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26392. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26393. getRadius(impostor: PhysicsImpostor): number;
  26394. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26395. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26396. dispose(): void;
  26397. }
  26398. /**
  26399. * Interface used to define a physics engine
  26400. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26401. */
  26402. export interface IPhysicsEngine {
  26403. /**
  26404. * Gets the gravity vector used by the simulation
  26405. */
  26406. gravity: Vector3;
  26407. /**
  26408. * Sets the gravity vector used by the simulation
  26409. * @param gravity defines the gravity vector to use
  26410. */
  26411. setGravity(gravity: Vector3): void;
  26412. /**
  26413. * Set the time step of the physics engine.
  26414. * Default is 1/60.
  26415. * To slow it down, enter 1/600 for example.
  26416. * To speed it up, 1/30
  26417. * @param newTimeStep the new timestep to apply to this world.
  26418. */
  26419. setTimeStep(newTimeStep: number): void;
  26420. /**
  26421. * Get the time step of the physics engine.
  26422. * @returns the current time step
  26423. */
  26424. getTimeStep(): number;
  26425. /**
  26426. * Set the sub time step of the physics engine.
  26427. * Default is 0 meaning there is no sub steps
  26428. * To increase physics resolution precision, set a small value (like 1 ms)
  26429. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26430. */
  26431. setSubTimeStep(subTimeStep: number): void;
  26432. /**
  26433. * Get the sub time step of the physics engine.
  26434. * @returns the current sub time step
  26435. */
  26436. getSubTimeStep(): number;
  26437. /**
  26438. * Release all resources
  26439. */
  26440. dispose(): void;
  26441. /**
  26442. * Gets the name of the current physics plugin
  26443. * @returns the name of the plugin
  26444. */
  26445. getPhysicsPluginName(): string;
  26446. /**
  26447. * Adding a new impostor for the impostor tracking.
  26448. * This will be done by the impostor itself.
  26449. * @param impostor the impostor to add
  26450. */
  26451. addImpostor(impostor: PhysicsImpostor): void;
  26452. /**
  26453. * Remove an impostor from the engine.
  26454. * This impostor and its mesh will not longer be updated by the physics engine.
  26455. * @param impostor the impostor to remove
  26456. */
  26457. removeImpostor(impostor: PhysicsImpostor): void;
  26458. /**
  26459. * Add a joint to the physics engine
  26460. * @param mainImpostor defines the main impostor to which the joint is added.
  26461. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26462. * @param joint defines the joint that will connect both impostors.
  26463. */
  26464. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26465. /**
  26466. * Removes a joint from the simulation
  26467. * @param mainImpostor defines the impostor used with the joint
  26468. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26469. * @param joint defines the joint to remove
  26470. */
  26471. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26472. /**
  26473. * Gets the current plugin used to run the simulation
  26474. * @returns current plugin
  26475. */
  26476. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26477. /**
  26478. * Gets the list of physic impostors
  26479. * @returns an array of PhysicsImpostor
  26480. */
  26481. getImpostors(): Array<PhysicsImpostor>;
  26482. /**
  26483. * Gets the impostor for a physics enabled object
  26484. * @param object defines the object impersonated by the impostor
  26485. * @returns the PhysicsImpostor or null if not found
  26486. */
  26487. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26488. /**
  26489. * Gets the impostor for a physics body object
  26490. * @param body defines physics body used by the impostor
  26491. * @returns the PhysicsImpostor or null if not found
  26492. */
  26493. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26494. /**
  26495. * Does a raycast in the physics world
  26496. * @param from when should the ray start?
  26497. * @param to when should the ray end?
  26498. * @returns PhysicsRaycastResult
  26499. */
  26500. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26501. /**
  26502. * Called by the scene. No need to call it.
  26503. * @param delta defines the timespam between frames
  26504. */
  26505. _step(delta: number): void;
  26506. }
  26507. }
  26508. declare module BABYLON {
  26509. /**
  26510. * The interface for the physics imposter parameters
  26511. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26512. */
  26513. export interface PhysicsImpostorParameters {
  26514. /**
  26515. * The mass of the physics imposter
  26516. */
  26517. mass: number;
  26518. /**
  26519. * The friction of the physics imposter
  26520. */
  26521. friction?: number;
  26522. /**
  26523. * The coefficient of restitution of the physics imposter
  26524. */
  26525. restitution?: number;
  26526. /**
  26527. * The native options of the physics imposter
  26528. */
  26529. nativeOptions?: any;
  26530. /**
  26531. * Specifies if the parent should be ignored
  26532. */
  26533. ignoreParent?: boolean;
  26534. /**
  26535. * Specifies if bi-directional transformations should be disabled
  26536. */
  26537. disableBidirectionalTransformation?: boolean;
  26538. /**
  26539. * The pressure inside the physics imposter, soft object only
  26540. */
  26541. pressure?: number;
  26542. /**
  26543. * The stiffness the physics imposter, soft object only
  26544. */
  26545. stiffness?: number;
  26546. /**
  26547. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26548. */
  26549. velocityIterations?: number;
  26550. /**
  26551. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26552. */
  26553. positionIterations?: number;
  26554. /**
  26555. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26556. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26557. * Add to fix multiple points
  26558. */
  26559. fixedPoints?: number;
  26560. /**
  26561. * The collision margin around a soft object
  26562. */
  26563. margin?: number;
  26564. /**
  26565. * The collision margin around a soft object
  26566. */
  26567. damping?: number;
  26568. /**
  26569. * The path for a rope based on an extrusion
  26570. */
  26571. path?: any;
  26572. /**
  26573. * The shape of an extrusion used for a rope based on an extrusion
  26574. */
  26575. shape?: any;
  26576. }
  26577. /**
  26578. * Interface for a physics-enabled object
  26579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26580. */
  26581. export interface IPhysicsEnabledObject {
  26582. /**
  26583. * The position of the physics-enabled object
  26584. */
  26585. position: Vector3;
  26586. /**
  26587. * The rotation of the physics-enabled object
  26588. */
  26589. rotationQuaternion: Nullable<Quaternion>;
  26590. /**
  26591. * The scale of the physics-enabled object
  26592. */
  26593. scaling: Vector3;
  26594. /**
  26595. * The rotation of the physics-enabled object
  26596. */
  26597. rotation?: Vector3;
  26598. /**
  26599. * The parent of the physics-enabled object
  26600. */
  26601. parent?: any;
  26602. /**
  26603. * The bounding info of the physics-enabled object
  26604. * @returns The bounding info of the physics-enabled object
  26605. */
  26606. getBoundingInfo(): BoundingInfo;
  26607. /**
  26608. * Computes the world matrix
  26609. * @param force Specifies if the world matrix should be computed by force
  26610. * @returns A world matrix
  26611. */
  26612. computeWorldMatrix(force: boolean): Matrix;
  26613. /**
  26614. * Gets the world matrix
  26615. * @returns A world matrix
  26616. */
  26617. getWorldMatrix?(): Matrix;
  26618. /**
  26619. * Gets the child meshes
  26620. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26621. * @returns An array of abstract meshes
  26622. */
  26623. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26624. /**
  26625. * Gets the vertex data
  26626. * @param kind The type of vertex data
  26627. * @returns A nullable array of numbers, or a float32 array
  26628. */
  26629. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26630. /**
  26631. * Gets the indices from the mesh
  26632. * @returns A nullable array of index arrays
  26633. */
  26634. getIndices?(): Nullable<IndicesArray>;
  26635. /**
  26636. * Gets the scene from the mesh
  26637. * @returns the indices array or null
  26638. */
  26639. getScene?(): Scene;
  26640. /**
  26641. * Gets the absolute position from the mesh
  26642. * @returns the absolute position
  26643. */
  26644. getAbsolutePosition(): Vector3;
  26645. /**
  26646. * Gets the absolute pivot point from the mesh
  26647. * @returns the absolute pivot point
  26648. */
  26649. getAbsolutePivotPoint(): Vector3;
  26650. /**
  26651. * Rotates the mesh
  26652. * @param axis The axis of rotation
  26653. * @param amount The amount of rotation
  26654. * @param space The space of the rotation
  26655. * @returns The rotation transform node
  26656. */
  26657. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26658. /**
  26659. * Translates the mesh
  26660. * @param axis The axis of translation
  26661. * @param distance The distance of translation
  26662. * @param space The space of the translation
  26663. * @returns The transform node
  26664. */
  26665. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26666. /**
  26667. * Sets the absolute position of the mesh
  26668. * @param absolutePosition The absolute position of the mesh
  26669. * @returns The transform node
  26670. */
  26671. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26672. /**
  26673. * Gets the class name of the mesh
  26674. * @returns The class name
  26675. */
  26676. getClassName(): string;
  26677. }
  26678. /**
  26679. * Represents a physics imposter
  26680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26681. */
  26682. export class PhysicsImpostor {
  26683. /**
  26684. * The physics-enabled object used as the physics imposter
  26685. */
  26686. object: IPhysicsEnabledObject;
  26687. /**
  26688. * The type of the physics imposter
  26689. */
  26690. type: number;
  26691. private _options;
  26692. private _scene?;
  26693. /**
  26694. * The default object size of the imposter
  26695. */
  26696. static DEFAULT_OBJECT_SIZE: Vector3;
  26697. /**
  26698. * The identity quaternion of the imposter
  26699. */
  26700. static IDENTITY_QUATERNION: Quaternion;
  26701. /** @hidden */
  26702. _pluginData: any;
  26703. private _physicsEngine;
  26704. private _physicsBody;
  26705. private _bodyUpdateRequired;
  26706. private _onBeforePhysicsStepCallbacks;
  26707. private _onAfterPhysicsStepCallbacks;
  26708. /** @hidden */
  26709. _onPhysicsCollideCallbacks: Array<{
  26710. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26711. otherImpostors: Array<PhysicsImpostor>;
  26712. }>;
  26713. private _deltaPosition;
  26714. private _deltaRotation;
  26715. private _deltaRotationConjugated;
  26716. /** @hidden */
  26717. _isFromLine: boolean;
  26718. private _parent;
  26719. private _isDisposed;
  26720. private static _tmpVecs;
  26721. private static _tmpQuat;
  26722. /**
  26723. * Specifies if the physics imposter is disposed
  26724. */
  26725. get isDisposed(): boolean;
  26726. /**
  26727. * Gets the mass of the physics imposter
  26728. */
  26729. get mass(): number;
  26730. set mass(value: number);
  26731. /**
  26732. * Gets the coefficient of friction
  26733. */
  26734. get friction(): number;
  26735. /**
  26736. * Sets the coefficient of friction
  26737. */
  26738. set friction(value: number);
  26739. /**
  26740. * Gets the coefficient of restitution
  26741. */
  26742. get restitution(): number;
  26743. /**
  26744. * Sets the coefficient of restitution
  26745. */
  26746. set restitution(value: number);
  26747. /**
  26748. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26749. */
  26750. get pressure(): number;
  26751. /**
  26752. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26753. */
  26754. set pressure(value: number);
  26755. /**
  26756. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26757. */
  26758. get stiffness(): number;
  26759. /**
  26760. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26761. */
  26762. set stiffness(value: number);
  26763. /**
  26764. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26765. */
  26766. get velocityIterations(): number;
  26767. /**
  26768. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26769. */
  26770. set velocityIterations(value: number);
  26771. /**
  26772. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26773. */
  26774. get positionIterations(): number;
  26775. /**
  26776. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26777. */
  26778. set positionIterations(value: number);
  26779. /**
  26780. * The unique id of the physics imposter
  26781. * set by the physics engine when adding this impostor to the array
  26782. */
  26783. uniqueId: number;
  26784. /**
  26785. * @hidden
  26786. */
  26787. soft: boolean;
  26788. /**
  26789. * @hidden
  26790. */
  26791. segments: number;
  26792. private _joints;
  26793. /**
  26794. * Initializes the physics imposter
  26795. * @param object The physics-enabled object used as the physics imposter
  26796. * @param type The type of the physics imposter
  26797. * @param _options The options for the physics imposter
  26798. * @param _scene The Babylon scene
  26799. */
  26800. constructor(
  26801. /**
  26802. * The physics-enabled object used as the physics imposter
  26803. */
  26804. object: IPhysicsEnabledObject,
  26805. /**
  26806. * The type of the physics imposter
  26807. */
  26808. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26809. /**
  26810. * This function will completly initialize this impostor.
  26811. * It will create a new body - but only if this mesh has no parent.
  26812. * If it has, this impostor will not be used other than to define the impostor
  26813. * of the child mesh.
  26814. * @hidden
  26815. */
  26816. _init(): void;
  26817. private _getPhysicsParent;
  26818. /**
  26819. * Should a new body be generated.
  26820. * @returns boolean specifying if body initialization is required
  26821. */
  26822. isBodyInitRequired(): boolean;
  26823. /**
  26824. * Sets the updated scaling
  26825. * @param updated Specifies if the scaling is updated
  26826. */
  26827. setScalingUpdated(): void;
  26828. /**
  26829. * Force a regeneration of this or the parent's impostor's body.
  26830. * Use under cautious - This will remove all joints already implemented.
  26831. */
  26832. forceUpdate(): void;
  26833. /**
  26834. * Gets the body that holds this impostor. Either its own, or its parent.
  26835. */
  26836. get physicsBody(): any;
  26837. /**
  26838. * Get the parent of the physics imposter
  26839. * @returns Physics imposter or null
  26840. */
  26841. get parent(): Nullable<PhysicsImpostor>;
  26842. /**
  26843. * Sets the parent of the physics imposter
  26844. */
  26845. set parent(value: Nullable<PhysicsImpostor>);
  26846. /**
  26847. * Set the physics body. Used mainly by the physics engine/plugin
  26848. */
  26849. set physicsBody(physicsBody: any);
  26850. /**
  26851. * Resets the update flags
  26852. */
  26853. resetUpdateFlags(): void;
  26854. /**
  26855. * Gets the object extend size
  26856. * @returns the object extend size
  26857. */
  26858. getObjectExtendSize(): Vector3;
  26859. /**
  26860. * Gets the object center
  26861. * @returns The object center
  26862. */
  26863. getObjectCenter(): Vector3;
  26864. /**
  26865. * Get a specific parameter from the options parameters
  26866. * @param paramName The object parameter name
  26867. * @returns The object parameter
  26868. */
  26869. getParam(paramName: string): any;
  26870. /**
  26871. * Sets a specific parameter in the options given to the physics plugin
  26872. * @param paramName The parameter name
  26873. * @param value The value of the parameter
  26874. */
  26875. setParam(paramName: string, value: number): void;
  26876. /**
  26877. * Specifically change the body's mass option. Won't recreate the physics body object
  26878. * @param mass The mass of the physics imposter
  26879. */
  26880. setMass(mass: number): void;
  26881. /**
  26882. * Gets the linear velocity
  26883. * @returns linear velocity or null
  26884. */
  26885. getLinearVelocity(): Nullable<Vector3>;
  26886. /**
  26887. * Sets the linear velocity
  26888. * @param velocity linear velocity or null
  26889. */
  26890. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26891. /**
  26892. * Gets the angular velocity
  26893. * @returns angular velocity or null
  26894. */
  26895. getAngularVelocity(): Nullable<Vector3>;
  26896. /**
  26897. * Sets the angular velocity
  26898. * @param velocity The velocity or null
  26899. */
  26900. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26901. /**
  26902. * Execute a function with the physics plugin native code
  26903. * Provide a function the will have two variables - the world object and the physics body object
  26904. * @param func The function to execute with the physics plugin native code
  26905. */
  26906. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26907. /**
  26908. * Register a function that will be executed before the physics world is stepping forward
  26909. * @param func The function to execute before the physics world is stepped forward
  26910. */
  26911. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26912. /**
  26913. * Unregister a function that will be executed before the physics world is stepping forward
  26914. * @param func The function to execute before the physics world is stepped forward
  26915. */
  26916. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26917. /**
  26918. * Register a function that will be executed after the physics step
  26919. * @param func The function to execute after physics step
  26920. */
  26921. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26922. /**
  26923. * Unregisters a function that will be executed after the physics step
  26924. * @param func The function to execute after physics step
  26925. */
  26926. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26927. /**
  26928. * register a function that will be executed when this impostor collides against a different body
  26929. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26930. * @param func Callback that is executed on collision
  26931. */
  26932. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26933. /**
  26934. * Unregisters the physics imposter on contact
  26935. * @param collideAgainst The physics object to collide against
  26936. * @param func Callback to execute on collision
  26937. */
  26938. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26939. private _tmpQuat;
  26940. private _tmpQuat2;
  26941. /**
  26942. * Get the parent rotation
  26943. * @returns The parent rotation
  26944. */
  26945. getParentsRotation(): Quaternion;
  26946. /**
  26947. * this function is executed by the physics engine.
  26948. */
  26949. beforeStep: () => void;
  26950. /**
  26951. * this function is executed by the physics engine
  26952. */
  26953. afterStep: () => void;
  26954. /**
  26955. * Legacy collision detection event support
  26956. */
  26957. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26958. /**
  26959. * event and body object due to cannon's event-based architecture.
  26960. */
  26961. onCollide: (e: {
  26962. body: any;
  26963. }) => void;
  26964. /**
  26965. * Apply a force
  26966. * @param force The force to apply
  26967. * @param contactPoint The contact point for the force
  26968. * @returns The physics imposter
  26969. */
  26970. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26971. /**
  26972. * Apply an impulse
  26973. * @param force The impulse force
  26974. * @param contactPoint The contact point for the impulse force
  26975. * @returns The physics imposter
  26976. */
  26977. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26978. /**
  26979. * A help function to create a joint
  26980. * @param otherImpostor A physics imposter used to create a joint
  26981. * @param jointType The type of joint
  26982. * @param jointData The data for the joint
  26983. * @returns The physics imposter
  26984. */
  26985. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  26986. /**
  26987. * Add a joint to this impostor with a different impostor
  26988. * @param otherImpostor A physics imposter used to add a joint
  26989. * @param joint The joint to add
  26990. * @returns The physics imposter
  26991. */
  26992. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  26993. /**
  26994. * Add an anchor to a cloth impostor
  26995. * @param otherImpostor rigid impostor to anchor to
  26996. * @param width ratio across width from 0 to 1
  26997. * @param height ratio up height from 0 to 1
  26998. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  26999. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27000. * @returns impostor the soft imposter
  27001. */
  27002. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27003. /**
  27004. * Add a hook to a rope impostor
  27005. * @param otherImpostor rigid impostor to anchor to
  27006. * @param length ratio across rope from 0 to 1
  27007. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27008. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27009. * @returns impostor the rope imposter
  27010. */
  27011. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27012. /**
  27013. * Will keep this body still, in a sleep mode.
  27014. * @returns the physics imposter
  27015. */
  27016. sleep(): PhysicsImpostor;
  27017. /**
  27018. * Wake the body up.
  27019. * @returns The physics imposter
  27020. */
  27021. wakeUp(): PhysicsImpostor;
  27022. /**
  27023. * Clones the physics imposter
  27024. * @param newObject The physics imposter clones to this physics-enabled object
  27025. * @returns A nullable physics imposter
  27026. */
  27027. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27028. /**
  27029. * Disposes the physics imposter
  27030. */
  27031. dispose(): void;
  27032. /**
  27033. * Sets the delta position
  27034. * @param position The delta position amount
  27035. */
  27036. setDeltaPosition(position: Vector3): void;
  27037. /**
  27038. * Sets the delta rotation
  27039. * @param rotation The delta rotation amount
  27040. */
  27041. setDeltaRotation(rotation: Quaternion): void;
  27042. /**
  27043. * Gets the box size of the physics imposter and stores the result in the input parameter
  27044. * @param result Stores the box size
  27045. * @returns The physics imposter
  27046. */
  27047. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27048. /**
  27049. * Gets the radius of the physics imposter
  27050. * @returns Radius of the physics imposter
  27051. */
  27052. getRadius(): number;
  27053. /**
  27054. * Sync a bone with this impostor
  27055. * @param bone The bone to sync to the impostor.
  27056. * @param boneMesh The mesh that the bone is influencing.
  27057. * @param jointPivot The pivot of the joint / bone in local space.
  27058. * @param distToJoint Optional distance from the impostor to the joint.
  27059. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27060. */
  27061. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27062. /**
  27063. * Sync impostor to a bone
  27064. * @param bone The bone that the impostor will be synced to.
  27065. * @param boneMesh The mesh that the bone is influencing.
  27066. * @param jointPivot The pivot of the joint / bone in local space.
  27067. * @param distToJoint Optional distance from the impostor to the joint.
  27068. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27069. * @param boneAxis Optional vector3 axis the bone is aligned with
  27070. */
  27071. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27072. /**
  27073. * No-Imposter type
  27074. */
  27075. static NoImpostor: number;
  27076. /**
  27077. * Sphere-Imposter type
  27078. */
  27079. static SphereImpostor: number;
  27080. /**
  27081. * Box-Imposter type
  27082. */
  27083. static BoxImpostor: number;
  27084. /**
  27085. * Plane-Imposter type
  27086. */
  27087. static PlaneImpostor: number;
  27088. /**
  27089. * Mesh-imposter type
  27090. */
  27091. static MeshImpostor: number;
  27092. /**
  27093. * Capsule-Impostor type (Ammo.js plugin only)
  27094. */
  27095. static CapsuleImpostor: number;
  27096. /**
  27097. * Cylinder-Imposter type
  27098. */
  27099. static CylinderImpostor: number;
  27100. /**
  27101. * Particle-Imposter type
  27102. */
  27103. static ParticleImpostor: number;
  27104. /**
  27105. * Heightmap-Imposter type
  27106. */
  27107. static HeightmapImpostor: number;
  27108. /**
  27109. * ConvexHull-Impostor type (Ammo.js plugin only)
  27110. */
  27111. static ConvexHullImpostor: number;
  27112. /**
  27113. * Custom-Imposter type (Ammo.js plugin only)
  27114. */
  27115. static CustomImpostor: number;
  27116. /**
  27117. * Rope-Imposter type
  27118. */
  27119. static RopeImpostor: number;
  27120. /**
  27121. * Cloth-Imposter type
  27122. */
  27123. static ClothImpostor: number;
  27124. /**
  27125. * Softbody-Imposter type
  27126. */
  27127. static SoftbodyImpostor: number;
  27128. }
  27129. }
  27130. declare module BABYLON {
  27131. /**
  27132. * @hidden
  27133. **/
  27134. export class _CreationDataStorage {
  27135. closePath?: boolean;
  27136. closeArray?: boolean;
  27137. idx: number[];
  27138. dashSize: number;
  27139. gapSize: number;
  27140. path3D: Path3D;
  27141. pathArray: Vector3[][];
  27142. arc: number;
  27143. radius: number;
  27144. cap: number;
  27145. tessellation: number;
  27146. }
  27147. /**
  27148. * @hidden
  27149. **/
  27150. class _InstanceDataStorage {
  27151. visibleInstances: any;
  27152. batchCache: _InstancesBatch;
  27153. instancesBufferSize: number;
  27154. instancesBuffer: Nullable<Buffer>;
  27155. instancesData: Float32Array;
  27156. overridenInstanceCount: number;
  27157. isFrozen: boolean;
  27158. previousBatch: Nullable<_InstancesBatch>;
  27159. hardwareInstancedRendering: boolean;
  27160. sideOrientation: number;
  27161. manualUpdate: boolean;
  27162. }
  27163. /**
  27164. * @hidden
  27165. **/
  27166. export class _InstancesBatch {
  27167. mustReturn: boolean;
  27168. visibleInstances: Nullable<InstancedMesh[]>[];
  27169. renderSelf: boolean[];
  27170. hardwareInstancedRendering: boolean[];
  27171. }
  27172. /**
  27173. * @hidden
  27174. **/
  27175. class _ThinInstanceDataStorage {
  27176. instancesCount: number;
  27177. matrixBuffer: Nullable<Buffer>;
  27178. matrixBufferSize: number;
  27179. matrixData: Nullable<Float32Array>;
  27180. boundingVectors: Array<Vector3>;
  27181. }
  27182. /**
  27183. * Class used to represent renderable models
  27184. */
  27185. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27186. /**
  27187. * Mesh side orientation : usually the external or front surface
  27188. */
  27189. static readonly FRONTSIDE: number;
  27190. /**
  27191. * Mesh side orientation : usually the internal or back surface
  27192. */
  27193. static readonly BACKSIDE: number;
  27194. /**
  27195. * Mesh side orientation : both internal and external or front and back surfaces
  27196. */
  27197. static readonly DOUBLESIDE: number;
  27198. /**
  27199. * Mesh side orientation : by default, `FRONTSIDE`
  27200. */
  27201. static readonly DEFAULTSIDE: number;
  27202. /**
  27203. * Mesh cap setting : no cap
  27204. */
  27205. static readonly NO_CAP: number;
  27206. /**
  27207. * Mesh cap setting : one cap at the beginning of the mesh
  27208. */
  27209. static readonly CAP_START: number;
  27210. /**
  27211. * Mesh cap setting : one cap at the end of the mesh
  27212. */
  27213. static readonly CAP_END: number;
  27214. /**
  27215. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27216. */
  27217. static readonly CAP_ALL: number;
  27218. /**
  27219. * Mesh pattern setting : no flip or rotate
  27220. */
  27221. static readonly NO_FLIP: number;
  27222. /**
  27223. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27224. */
  27225. static readonly FLIP_TILE: number;
  27226. /**
  27227. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27228. */
  27229. static readonly ROTATE_TILE: number;
  27230. /**
  27231. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27232. */
  27233. static readonly FLIP_ROW: number;
  27234. /**
  27235. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27236. */
  27237. static readonly ROTATE_ROW: number;
  27238. /**
  27239. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27240. */
  27241. static readonly FLIP_N_ROTATE_TILE: number;
  27242. /**
  27243. * Mesh pattern setting : rotate pattern and rotate
  27244. */
  27245. static readonly FLIP_N_ROTATE_ROW: number;
  27246. /**
  27247. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27248. */
  27249. static readonly CENTER: number;
  27250. /**
  27251. * Mesh tile positioning : part tiles on left
  27252. */
  27253. static readonly LEFT: number;
  27254. /**
  27255. * Mesh tile positioning : part tiles on right
  27256. */
  27257. static readonly RIGHT: number;
  27258. /**
  27259. * Mesh tile positioning : part tiles on top
  27260. */
  27261. static readonly TOP: number;
  27262. /**
  27263. * Mesh tile positioning : part tiles on bottom
  27264. */
  27265. static readonly BOTTOM: number;
  27266. /**
  27267. * Gets the default side orientation.
  27268. * @param orientation the orientation to value to attempt to get
  27269. * @returns the default orientation
  27270. * @hidden
  27271. */
  27272. static _GetDefaultSideOrientation(orientation?: number): number;
  27273. private _internalMeshDataInfo;
  27274. /**
  27275. * An event triggered before rendering the mesh
  27276. */
  27277. get onBeforeRenderObservable(): Observable<Mesh>;
  27278. /**
  27279. * An event triggered before binding the mesh
  27280. */
  27281. get onBeforeBindObservable(): Observable<Mesh>;
  27282. /**
  27283. * An event triggered after rendering the mesh
  27284. */
  27285. get onAfterRenderObservable(): Observable<Mesh>;
  27286. /**
  27287. * An event triggered before drawing the mesh
  27288. */
  27289. get onBeforeDrawObservable(): Observable<Mesh>;
  27290. private _onBeforeDrawObserver;
  27291. /**
  27292. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27293. */
  27294. set onBeforeDraw(callback: () => void);
  27295. get hasInstances(): boolean;
  27296. get hasThinInstances(): boolean;
  27297. /**
  27298. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27299. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27300. */
  27301. delayLoadState: number;
  27302. /**
  27303. * Gets the list of instances created from this mesh
  27304. * it is not supposed to be modified manually.
  27305. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27306. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27307. */
  27308. instances: InstancedMesh[];
  27309. /**
  27310. * Gets the file containing delay loading data for this mesh
  27311. */
  27312. delayLoadingFile: string;
  27313. /** @hidden */
  27314. _binaryInfo: any;
  27315. /**
  27316. * User defined function used to change how LOD level selection is done
  27317. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27318. */
  27319. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27320. /**
  27321. * Gets or sets the morph target manager
  27322. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27323. */
  27324. get morphTargetManager(): Nullable<MorphTargetManager>;
  27325. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27326. /** @hidden */
  27327. _creationDataStorage: Nullable<_CreationDataStorage>;
  27328. /** @hidden */
  27329. _geometry: Nullable<Geometry>;
  27330. /** @hidden */
  27331. _delayInfo: Array<string>;
  27332. /** @hidden */
  27333. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27334. /** @hidden */
  27335. _instanceDataStorage: _InstanceDataStorage;
  27336. /** @hidden */
  27337. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27338. private _effectiveMaterial;
  27339. /** @hidden */
  27340. _shouldGenerateFlatShading: boolean;
  27341. /** @hidden */
  27342. _originalBuilderSideOrientation: number;
  27343. /**
  27344. * Use this property to change the original side orientation defined at construction time
  27345. */
  27346. overrideMaterialSideOrientation: Nullable<number>;
  27347. /**
  27348. * Gets the source mesh (the one used to clone this one from)
  27349. */
  27350. get source(): Nullable<Mesh>;
  27351. /**
  27352. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27353. */
  27354. get isUnIndexed(): boolean;
  27355. set isUnIndexed(value: boolean);
  27356. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27357. get worldMatrixInstancedBuffer(): Float32Array;
  27358. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27359. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27360. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27361. /**
  27362. * @constructor
  27363. * @param name The value used by scene.getMeshByName() to do a lookup.
  27364. * @param scene The scene to add this mesh to.
  27365. * @param parent The parent of this mesh, if it has one
  27366. * @param source An optional Mesh from which geometry is shared, cloned.
  27367. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27368. * When false, achieved by calling a clone(), also passing False.
  27369. * This will make creation of children, recursive.
  27370. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27371. */
  27372. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27373. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27374. doNotInstantiate: boolean;
  27375. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27376. /**
  27377. * Gets the class name
  27378. * @returns the string "Mesh".
  27379. */
  27380. getClassName(): string;
  27381. /** @hidden */
  27382. get _isMesh(): boolean;
  27383. /**
  27384. * Returns a description of this mesh
  27385. * @param fullDetails define if full details about this mesh must be used
  27386. * @returns a descriptive string representing this mesh
  27387. */
  27388. toString(fullDetails?: boolean): string;
  27389. /** @hidden */
  27390. _unBindEffect(): void;
  27391. /**
  27392. * Gets a boolean indicating if this mesh has LOD
  27393. */
  27394. get hasLODLevels(): boolean;
  27395. /**
  27396. * Gets the list of MeshLODLevel associated with the current mesh
  27397. * @returns an array of MeshLODLevel
  27398. */
  27399. getLODLevels(): MeshLODLevel[];
  27400. private _sortLODLevels;
  27401. /**
  27402. * Add a mesh as LOD level triggered at the given distance.
  27403. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27404. * @param distance The distance from the center of the object to show this level
  27405. * @param mesh The mesh to be added as LOD level (can be null)
  27406. * @return This mesh (for chaining)
  27407. */
  27408. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27409. /**
  27410. * Returns the LOD level mesh at the passed distance or null if not found.
  27411. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27412. * @param distance The distance from the center of the object to show this level
  27413. * @returns a Mesh or `null`
  27414. */
  27415. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27416. /**
  27417. * Remove a mesh from the LOD array
  27418. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27419. * @param mesh defines the mesh to be removed
  27420. * @return This mesh (for chaining)
  27421. */
  27422. removeLODLevel(mesh: Mesh): Mesh;
  27423. /**
  27424. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27425. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27426. * @param camera defines the camera to use to compute distance
  27427. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27428. * @return This mesh (for chaining)
  27429. */
  27430. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27431. /**
  27432. * Gets the mesh internal Geometry object
  27433. */
  27434. get geometry(): Nullable<Geometry>;
  27435. /**
  27436. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27437. * @returns the total number of vertices
  27438. */
  27439. getTotalVertices(): number;
  27440. /**
  27441. * Returns the content of an associated vertex buffer
  27442. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27443. * - VertexBuffer.PositionKind
  27444. * - VertexBuffer.UVKind
  27445. * - VertexBuffer.UV2Kind
  27446. * - VertexBuffer.UV3Kind
  27447. * - VertexBuffer.UV4Kind
  27448. * - VertexBuffer.UV5Kind
  27449. * - VertexBuffer.UV6Kind
  27450. * - VertexBuffer.ColorKind
  27451. * - VertexBuffer.MatricesIndicesKind
  27452. * - VertexBuffer.MatricesIndicesExtraKind
  27453. * - VertexBuffer.MatricesWeightsKind
  27454. * - VertexBuffer.MatricesWeightsExtraKind
  27455. * @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
  27456. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27457. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27458. */
  27459. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27460. /**
  27461. * Returns the mesh VertexBuffer object from the requested `kind`
  27462. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27463. * - VertexBuffer.PositionKind
  27464. * - VertexBuffer.NormalKind
  27465. * - VertexBuffer.UVKind
  27466. * - VertexBuffer.UV2Kind
  27467. * - VertexBuffer.UV3Kind
  27468. * - VertexBuffer.UV4Kind
  27469. * - VertexBuffer.UV5Kind
  27470. * - VertexBuffer.UV6Kind
  27471. * - VertexBuffer.ColorKind
  27472. * - VertexBuffer.MatricesIndicesKind
  27473. * - VertexBuffer.MatricesIndicesExtraKind
  27474. * - VertexBuffer.MatricesWeightsKind
  27475. * - VertexBuffer.MatricesWeightsExtraKind
  27476. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27477. */
  27478. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27479. /**
  27480. * Tests if a specific vertex buffer is associated with this mesh
  27481. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27482. * - VertexBuffer.PositionKind
  27483. * - VertexBuffer.NormalKind
  27484. * - VertexBuffer.UVKind
  27485. * - VertexBuffer.UV2Kind
  27486. * - VertexBuffer.UV3Kind
  27487. * - VertexBuffer.UV4Kind
  27488. * - VertexBuffer.UV5Kind
  27489. * - VertexBuffer.UV6Kind
  27490. * - VertexBuffer.ColorKind
  27491. * - VertexBuffer.MatricesIndicesKind
  27492. * - VertexBuffer.MatricesIndicesExtraKind
  27493. * - VertexBuffer.MatricesWeightsKind
  27494. * - VertexBuffer.MatricesWeightsExtraKind
  27495. * @returns a boolean
  27496. */
  27497. isVerticesDataPresent(kind: string): boolean;
  27498. /**
  27499. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27500. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27501. * - VertexBuffer.PositionKind
  27502. * - VertexBuffer.UVKind
  27503. * - VertexBuffer.UV2Kind
  27504. * - VertexBuffer.UV3Kind
  27505. * - VertexBuffer.UV4Kind
  27506. * - VertexBuffer.UV5Kind
  27507. * - VertexBuffer.UV6Kind
  27508. * - VertexBuffer.ColorKind
  27509. * - VertexBuffer.MatricesIndicesKind
  27510. * - VertexBuffer.MatricesIndicesExtraKind
  27511. * - VertexBuffer.MatricesWeightsKind
  27512. * - VertexBuffer.MatricesWeightsExtraKind
  27513. * @returns a boolean
  27514. */
  27515. isVertexBufferUpdatable(kind: string): boolean;
  27516. /**
  27517. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27518. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27519. * - VertexBuffer.PositionKind
  27520. * - VertexBuffer.NormalKind
  27521. * - VertexBuffer.UVKind
  27522. * - VertexBuffer.UV2Kind
  27523. * - VertexBuffer.UV3Kind
  27524. * - VertexBuffer.UV4Kind
  27525. * - VertexBuffer.UV5Kind
  27526. * - VertexBuffer.UV6Kind
  27527. * - VertexBuffer.ColorKind
  27528. * - VertexBuffer.MatricesIndicesKind
  27529. * - VertexBuffer.MatricesIndicesExtraKind
  27530. * - VertexBuffer.MatricesWeightsKind
  27531. * - VertexBuffer.MatricesWeightsExtraKind
  27532. * @returns an array of strings
  27533. */
  27534. getVerticesDataKinds(): string[];
  27535. /**
  27536. * Returns a positive integer : the total number of indices in this mesh geometry.
  27537. * @returns the numner of indices or zero if the mesh has no geometry.
  27538. */
  27539. getTotalIndices(): number;
  27540. /**
  27541. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27542. * @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.
  27543. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27544. * @returns the indices array or an empty array if the mesh has no geometry
  27545. */
  27546. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27547. get isBlocked(): boolean;
  27548. /**
  27549. * Determine if the current mesh is ready to be rendered
  27550. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27551. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27552. * @returns true if all associated assets are ready (material, textures, shaders)
  27553. */
  27554. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27555. /**
  27556. * 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.
  27557. */
  27558. get areNormalsFrozen(): boolean;
  27559. /**
  27560. * 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.
  27561. * @returns the current mesh
  27562. */
  27563. freezeNormals(): Mesh;
  27564. /**
  27565. * 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
  27566. * @returns the current mesh
  27567. */
  27568. unfreezeNormals(): Mesh;
  27569. /**
  27570. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27571. */
  27572. set overridenInstanceCount(count: number);
  27573. /** @hidden */
  27574. _preActivate(): Mesh;
  27575. /** @hidden */
  27576. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27577. /** @hidden */
  27578. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27579. protected _afterComputeWorldMatrix(): void;
  27580. /**
  27581. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27582. * This means the mesh underlying bounding box and sphere are recomputed.
  27583. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27584. * @returns the current mesh
  27585. */
  27586. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27587. /** @hidden */
  27588. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27589. /**
  27590. * This function will subdivide the mesh into multiple submeshes
  27591. * @param count defines the expected number of submeshes
  27592. */
  27593. subdivide(count: number): void;
  27594. /**
  27595. * Copy a FloatArray into a specific associated vertex buffer
  27596. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27597. * - VertexBuffer.PositionKind
  27598. * - VertexBuffer.UVKind
  27599. * - VertexBuffer.UV2Kind
  27600. * - VertexBuffer.UV3Kind
  27601. * - VertexBuffer.UV4Kind
  27602. * - VertexBuffer.UV5Kind
  27603. * - VertexBuffer.UV6Kind
  27604. * - VertexBuffer.ColorKind
  27605. * - VertexBuffer.MatricesIndicesKind
  27606. * - VertexBuffer.MatricesIndicesExtraKind
  27607. * - VertexBuffer.MatricesWeightsKind
  27608. * - VertexBuffer.MatricesWeightsExtraKind
  27609. * @param data defines the data source
  27610. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27611. * @param stride defines the data stride size (can be null)
  27612. * @returns the current mesh
  27613. */
  27614. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27615. /**
  27616. * Delete a vertex buffer associated with this mesh
  27617. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27618. * - VertexBuffer.PositionKind
  27619. * - VertexBuffer.UVKind
  27620. * - VertexBuffer.UV2Kind
  27621. * - VertexBuffer.UV3Kind
  27622. * - VertexBuffer.UV4Kind
  27623. * - VertexBuffer.UV5Kind
  27624. * - VertexBuffer.UV6Kind
  27625. * - VertexBuffer.ColorKind
  27626. * - VertexBuffer.MatricesIndicesKind
  27627. * - VertexBuffer.MatricesIndicesExtraKind
  27628. * - VertexBuffer.MatricesWeightsKind
  27629. * - VertexBuffer.MatricesWeightsExtraKind
  27630. */
  27631. removeVerticesData(kind: string): void;
  27632. /**
  27633. * Flags an associated vertex buffer as updatable
  27634. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27635. * - VertexBuffer.PositionKind
  27636. * - VertexBuffer.UVKind
  27637. * - VertexBuffer.UV2Kind
  27638. * - VertexBuffer.UV3Kind
  27639. * - VertexBuffer.UV4Kind
  27640. * - VertexBuffer.UV5Kind
  27641. * - VertexBuffer.UV6Kind
  27642. * - VertexBuffer.ColorKind
  27643. * - VertexBuffer.MatricesIndicesKind
  27644. * - VertexBuffer.MatricesIndicesExtraKind
  27645. * - VertexBuffer.MatricesWeightsKind
  27646. * - VertexBuffer.MatricesWeightsExtraKind
  27647. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27648. */
  27649. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27650. /**
  27651. * Sets the mesh global Vertex Buffer
  27652. * @param buffer defines the buffer to use
  27653. * @returns the current mesh
  27654. */
  27655. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27656. /**
  27657. * Update a specific associated vertex buffer
  27658. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27659. * - VertexBuffer.PositionKind
  27660. * - VertexBuffer.UVKind
  27661. * - VertexBuffer.UV2Kind
  27662. * - VertexBuffer.UV3Kind
  27663. * - VertexBuffer.UV4Kind
  27664. * - VertexBuffer.UV5Kind
  27665. * - VertexBuffer.UV6Kind
  27666. * - VertexBuffer.ColorKind
  27667. * - VertexBuffer.MatricesIndicesKind
  27668. * - VertexBuffer.MatricesIndicesExtraKind
  27669. * - VertexBuffer.MatricesWeightsKind
  27670. * - VertexBuffer.MatricesWeightsExtraKind
  27671. * @param data defines the data source
  27672. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27673. * @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)
  27674. * @returns the current mesh
  27675. */
  27676. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27677. /**
  27678. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27679. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27680. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27681. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27682. * @returns the current mesh
  27683. */
  27684. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27685. /**
  27686. * Creates a un-shared specific occurence of the geometry for the mesh.
  27687. * @returns the current mesh
  27688. */
  27689. makeGeometryUnique(): Mesh;
  27690. /**
  27691. * Set the index buffer of this mesh
  27692. * @param indices defines the source data
  27693. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27694. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27695. * @returns the current mesh
  27696. */
  27697. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27698. /**
  27699. * Update the current index buffer
  27700. * @param indices defines the source data
  27701. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27702. * @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)
  27703. * @returns the current mesh
  27704. */
  27705. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27706. /**
  27707. * Invert the geometry to move from a right handed system to a left handed one.
  27708. * @returns the current mesh
  27709. */
  27710. toLeftHanded(): Mesh;
  27711. /** @hidden */
  27712. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27713. /** @hidden */
  27714. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27715. /**
  27716. * Registers for this mesh a javascript function called just before the rendering process
  27717. * @param func defines the function to call before rendering this mesh
  27718. * @returns the current mesh
  27719. */
  27720. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27721. /**
  27722. * Disposes a previously registered javascript function called before the rendering
  27723. * @param func defines the function to remove
  27724. * @returns the current mesh
  27725. */
  27726. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27727. /**
  27728. * Registers for this mesh a javascript function called just after the rendering is complete
  27729. * @param func defines the function to call after rendering this mesh
  27730. * @returns the current mesh
  27731. */
  27732. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27733. /**
  27734. * Disposes a previously registered javascript function called after the rendering.
  27735. * @param func defines the function to remove
  27736. * @returns the current mesh
  27737. */
  27738. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27739. /** @hidden */
  27740. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27741. /** @hidden */
  27742. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27743. /** @hidden */
  27744. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27745. /** @hidden */
  27746. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27747. /** @hidden */
  27748. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27749. /** @hidden */
  27750. _rebuild(): void;
  27751. /** @hidden */
  27752. _freeze(): void;
  27753. /** @hidden */
  27754. _unFreeze(): void;
  27755. /**
  27756. * 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
  27757. * @param subMesh defines the subMesh to render
  27758. * @param enableAlphaMode defines if alpha mode can be changed
  27759. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27760. * @returns the current mesh
  27761. */
  27762. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27763. private _onBeforeDraw;
  27764. /**
  27765. * Renormalize the mesh and patch it up if there are no weights
  27766. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27767. * However in the case of zero weights then we set just a single influence to 1.
  27768. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27769. */
  27770. cleanMatrixWeights(): void;
  27771. private normalizeSkinFourWeights;
  27772. private normalizeSkinWeightsAndExtra;
  27773. /**
  27774. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27775. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27776. * the user know there was an issue with importing the mesh
  27777. * @returns a validation object with skinned, valid and report string
  27778. */
  27779. validateSkinning(): {
  27780. skinned: boolean;
  27781. valid: boolean;
  27782. report: string;
  27783. };
  27784. /** @hidden */
  27785. _checkDelayState(): Mesh;
  27786. private _queueLoad;
  27787. /**
  27788. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27789. * A mesh is in the frustum if its bounding box intersects the frustum
  27790. * @param frustumPlanes defines the frustum to test
  27791. * @returns true if the mesh is in the frustum planes
  27792. */
  27793. isInFrustum(frustumPlanes: Plane[]): boolean;
  27794. /**
  27795. * Sets the mesh material by the material or multiMaterial `id` property
  27796. * @param id is a string identifying the material or the multiMaterial
  27797. * @returns the current mesh
  27798. */
  27799. setMaterialByID(id: string): Mesh;
  27800. /**
  27801. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27802. * @returns an array of IAnimatable
  27803. */
  27804. getAnimatables(): IAnimatable[];
  27805. /**
  27806. * Modifies the mesh geometry according to the passed transformation matrix.
  27807. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27808. * The mesh normals are modified using the same transformation.
  27809. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27810. * @param transform defines the transform matrix to use
  27811. * @see http://doc.babylonjs.com/resources/baking_transformations
  27812. * @returns the current mesh
  27813. */
  27814. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27815. /**
  27816. * Modifies the mesh geometry according to its own current World Matrix.
  27817. * The mesh World Matrix is then reset.
  27818. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27819. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27820. * @see http://doc.babylonjs.com/resources/baking_transformations
  27821. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27822. * @returns the current mesh
  27823. */
  27824. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27825. /** @hidden */
  27826. get _positions(): Nullable<Vector3[]>;
  27827. /** @hidden */
  27828. _resetPointsArrayCache(): Mesh;
  27829. /** @hidden */
  27830. _generatePointsArray(): boolean;
  27831. /**
  27832. * Returns a new Mesh object generated from the current mesh properties.
  27833. * This method must not get confused with createInstance()
  27834. * @param name is a string, the name given to the new mesh
  27835. * @param newParent can be any Node object (default `null`)
  27836. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27837. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27838. * @returns a new mesh
  27839. */
  27840. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27841. /**
  27842. * Releases resources associated with this mesh.
  27843. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27844. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27845. */
  27846. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27847. /** @hidden */
  27848. _disposeInstanceSpecificData(): void;
  27849. /** @hidden */
  27850. _disposeThinInstanceSpecificData(): void;
  27851. /**
  27852. * Modifies the mesh geometry according to a displacement map.
  27853. * 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.
  27854. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27855. * @param url is a string, the URL from the image file is to be downloaded.
  27856. * @param minHeight is the lower limit of the displacement.
  27857. * @param maxHeight is the upper limit of the displacement.
  27858. * @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.
  27859. * @param uvOffset is an optional vector2 used to offset UV.
  27860. * @param uvScale is an optional vector2 used to scale UV.
  27861. * @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.
  27862. * @returns the Mesh.
  27863. */
  27864. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27865. /**
  27866. * Modifies the mesh geometry according to a displacementMap buffer.
  27867. * 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.
  27868. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27869. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27870. * @param heightMapWidth is the width of the buffer image.
  27871. * @param heightMapHeight is the height of the buffer image.
  27872. * @param minHeight is the lower limit of the displacement.
  27873. * @param maxHeight is the upper limit of the displacement.
  27874. * @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.
  27875. * @param uvOffset is an optional vector2 used to offset UV.
  27876. * @param uvScale is an optional vector2 used to scale UV.
  27877. * @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.
  27878. * @returns the Mesh.
  27879. */
  27880. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27881. /**
  27882. * Modify the mesh to get a flat shading rendering.
  27883. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27884. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27885. * @returns current mesh
  27886. */
  27887. convertToFlatShadedMesh(): Mesh;
  27888. /**
  27889. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27890. * In other words, more vertices, no more indices and a single bigger VBO.
  27891. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27892. * @returns current mesh
  27893. */
  27894. convertToUnIndexedMesh(): Mesh;
  27895. /**
  27896. * Inverses facet orientations.
  27897. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27898. * @param flipNormals will also inverts the normals
  27899. * @returns current mesh
  27900. */
  27901. flipFaces(flipNormals?: boolean): Mesh;
  27902. /**
  27903. * Increase the number of facets and hence vertices in a mesh
  27904. * Vertex normals are interpolated from existing vertex normals
  27905. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27906. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27907. */
  27908. increaseVertices(numberPerEdge: number): void;
  27909. /**
  27910. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27911. * This will undo any application of covertToFlatShadedMesh
  27912. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27913. */
  27914. forceSharedVertices(): void;
  27915. /** @hidden */
  27916. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27917. /** @hidden */
  27918. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27919. /**
  27920. * Creates a new InstancedMesh object from the mesh model.
  27921. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27922. * @param name defines the name of the new instance
  27923. * @returns a new InstancedMesh
  27924. */
  27925. createInstance(name: string): InstancedMesh;
  27926. /**
  27927. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27928. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27929. * @returns the current mesh
  27930. */
  27931. synchronizeInstances(): Mesh;
  27932. /**
  27933. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27934. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27935. * This should be used together with the simplification to avoid disappearing triangles.
  27936. * @param successCallback an optional success callback to be called after the optimization finished.
  27937. * @returns the current mesh
  27938. */
  27939. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27940. /**
  27941. * Serialize current mesh
  27942. * @param serializationObject defines the object which will receive the serialization data
  27943. */
  27944. serialize(serializationObject: any): void;
  27945. /** @hidden */
  27946. _syncGeometryWithMorphTargetManager(): void;
  27947. /** @hidden */
  27948. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27949. /**
  27950. * Returns a new Mesh object parsed from the source provided.
  27951. * @param parsedMesh is the source
  27952. * @param scene defines the hosting scene
  27953. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27954. * @returns a new Mesh
  27955. */
  27956. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27957. /**
  27958. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27959. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27960. * @param name defines the name of the mesh to create
  27961. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27962. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27963. * @param closePath creates a seam between the first and the last points of each path of the path array
  27964. * @param offset is taken in account only if the `pathArray` is containing a single path
  27965. * @param scene defines the hosting scene
  27966. * @param updatable defines if the mesh must be flagged as updatable
  27967. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27968. * @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)
  27969. * @returns a new Mesh
  27970. */
  27971. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27972. /**
  27973. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27974. * @param name defines the name of the mesh to create
  27975. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27976. * @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
  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 CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27983. /**
  27984. * Creates a box 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 size sets the size (float) of each box side (default 1)
  27987. * @param scene defines the hosting scene
  27988. * @param updatable defines if the mesh must be flagged as updatable
  27989. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27990. * @returns a new Mesh
  27991. */
  27992. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27993. /**
  27994. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27995. * @param name defines the name of the mesh to create
  27996. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27997. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27998. * @param scene defines the hosting scene
  27999. * @param updatable defines if the mesh must be flagged as updatable
  28000. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28001. * @returns a new Mesh
  28002. */
  28003. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28004. /**
  28005. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28006. * @param name defines the name of the mesh to create
  28007. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28008. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28009. * @param scene defines the hosting scene
  28010. * @returns a new Mesh
  28011. */
  28012. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28013. /**
  28014. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28015. * @param name defines the name of the mesh to create
  28016. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28017. * @param diameterTop set the top cap diameter (floats, default 1)
  28018. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28019. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28020. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28021. * @param scene defines the hosting scene
  28022. * @param updatable defines if the mesh must be flagged as updatable
  28023. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28024. * @returns a new Mesh
  28025. */
  28026. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28027. /**
  28028. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28029. * @param name defines the name of the mesh to create
  28030. * @param diameter sets the diameter size (float) of the torus (default 1)
  28031. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28032. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28033. * @param scene defines the hosting scene
  28034. * @param updatable defines if the mesh must be flagged as updatable
  28035. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28036. * @returns a new Mesh
  28037. */
  28038. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28039. /**
  28040. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28041. * @param name defines the name of the mesh to create
  28042. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28043. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28044. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28045. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28046. * @param p the number of windings on X axis (positive integers, default 2)
  28047. * @param q the number of windings on Y axis (positive integers, default 3)
  28048. * @param scene defines the hosting scene
  28049. * @param updatable defines if the mesh must be flagged as updatable
  28050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28051. * @returns a new Mesh
  28052. */
  28053. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28054. /**
  28055. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28056. * @param name defines the name of the mesh to create
  28057. * @param points is an array successive Vector3
  28058. * @param scene defines the hosting scene
  28059. * @param updatable defines if the mesh must be flagged as updatable
  28060. * @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).
  28061. * @returns a new Mesh
  28062. */
  28063. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28064. /**
  28065. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28066. * @param name defines the name of the mesh to create
  28067. * @param points is an array successive Vector3
  28068. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28069. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28070. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28071. * @param scene defines the hosting scene
  28072. * @param updatable defines if the mesh must be flagged as updatable
  28073. * @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)
  28074. * @returns a new Mesh
  28075. */
  28076. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28077. /**
  28078. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28079. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28080. * 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.
  28081. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28082. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28083. * Remember you can only change the shape positions, not their number when updating a polygon.
  28084. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28085. * @param name defines the name of the mesh to create
  28086. * @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
  28087. * @param scene defines the hosting scene
  28088. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28089. * @param updatable defines if the mesh must be flagged as updatable
  28090. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28091. * @param earcutInjection can be used to inject your own earcut reference
  28092. * @returns a new Mesh
  28093. */
  28094. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28095. /**
  28096. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28097. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28098. * @param name defines the name of the mesh to create
  28099. * @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
  28100. * @param depth defines the height of extrusion
  28101. * @param scene defines the hosting scene
  28102. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28103. * @param updatable defines if the mesh must be flagged as updatable
  28104. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28105. * @param earcutInjection can be used to inject your own earcut reference
  28106. * @returns a new Mesh
  28107. */
  28108. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28109. /**
  28110. * Creates an extruded shape mesh.
  28111. * 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
  28112. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28113. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28114. * @param name defines the name of the mesh to create
  28115. * @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
  28116. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28117. * @param scale is the value to scale the shape
  28118. * @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
  28119. * @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
  28120. * @param scene defines the hosting scene
  28121. * @param updatable defines if the mesh must be flagged as updatable
  28122. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28123. * @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)
  28124. * @returns a new Mesh
  28125. */
  28126. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28127. /**
  28128. * Creates an custom extruded shape mesh.
  28129. * The custom extrusion is a parametric shape.
  28130. * It has no predefined shape. Its final shape will depend on the input parameters.
  28131. * Please consider using the same method from the MeshBuilder class instead
  28132. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28133. * @param name defines the name of the mesh to create
  28134. * @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
  28135. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28136. * @param scaleFunction is a custom Javascript function called on each path point
  28137. * @param rotationFunction is a custom Javascript function called on each path point
  28138. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28139. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28140. * @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
  28141. * @param scene defines the hosting scene
  28142. * @param updatable defines if the mesh must be flagged as updatable
  28143. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28144. * @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)
  28145. * @returns a new Mesh
  28146. */
  28147. 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;
  28148. /**
  28149. * Creates lathe mesh.
  28150. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28151. * Please consider using the same method from the MeshBuilder class instead
  28152. * @param name defines the name of the mesh to create
  28153. * @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
  28154. * @param radius is the radius value of the lathe
  28155. * @param tessellation is the side number of the lathe.
  28156. * @param scene defines the hosting scene
  28157. * @param updatable defines if the mesh must be flagged as updatable
  28158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28159. * @returns a new Mesh
  28160. */
  28161. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28162. /**
  28163. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28164. * @param name defines the name of the mesh to create
  28165. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28166. * @param scene defines the hosting scene
  28167. * @param updatable defines if the mesh must be flagged as updatable
  28168. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28169. * @returns a new Mesh
  28170. */
  28171. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28172. /**
  28173. * Creates a ground mesh.
  28174. * Please consider using the same method from the MeshBuilder class instead
  28175. * @param name defines the name of the mesh to create
  28176. * @param width set the width of the ground
  28177. * @param height set the height of the ground
  28178. * @param subdivisions sets the number of subdivisions per side
  28179. * @param scene defines the hosting scene
  28180. * @param updatable defines if the mesh must be flagged as updatable
  28181. * @returns a new Mesh
  28182. */
  28183. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28184. /**
  28185. * Creates a tiled ground mesh.
  28186. * Please consider using the same method from the MeshBuilder class instead
  28187. * @param name defines the name of the mesh to create
  28188. * @param xmin set the ground minimum X coordinate
  28189. * @param zmin set the ground minimum Y coordinate
  28190. * @param xmax set the ground maximum X coordinate
  28191. * @param zmax set the ground maximum Z coordinate
  28192. * @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
  28193. * @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
  28194. * @param scene defines the hosting scene
  28195. * @param updatable defines if the mesh must be flagged as updatable
  28196. * @returns a new Mesh
  28197. */
  28198. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28199. w: number;
  28200. h: number;
  28201. }, precision: {
  28202. w: number;
  28203. h: number;
  28204. }, scene: Scene, updatable?: boolean): Mesh;
  28205. /**
  28206. * Creates a ground mesh from a height map.
  28207. * Please consider using the same method from the MeshBuilder class instead
  28208. * @see http://doc.babylonjs.com/babylon101/height_map
  28209. * @param name defines the name of the mesh to create
  28210. * @param url sets the URL of the height map image resource
  28211. * @param width set the ground width size
  28212. * @param height set the ground height size
  28213. * @param subdivisions sets the number of subdivision per side
  28214. * @param minHeight is the minimum altitude on the ground
  28215. * @param maxHeight is the maximum altitude on the ground
  28216. * @param scene defines the hosting scene
  28217. * @param updatable defines if the mesh must be flagged as updatable
  28218. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28219. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28220. * @returns a new Mesh
  28221. */
  28222. 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;
  28223. /**
  28224. * Creates a tube mesh.
  28225. * The tube is a parametric shape.
  28226. * It has no predefined shape. Its final shape will depend on the input parameters.
  28227. * Please consider using the same method from the MeshBuilder class instead
  28228. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28229. * @param name defines the name of the mesh to create
  28230. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28231. * @param radius sets the tube radius size
  28232. * @param tessellation is the number of sides on the tubular surface
  28233. * @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
  28234. * @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
  28235. * @param scene defines the hosting scene
  28236. * @param updatable defines if the mesh must be flagged as updatable
  28237. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28238. * @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)
  28239. * @returns a new Mesh
  28240. */
  28241. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28242. (i: number, distance: number): number;
  28243. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28244. /**
  28245. * Creates a polyhedron mesh.
  28246. * Please consider using the same method from the MeshBuilder class instead.
  28247. * * 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
  28248. * * The parameter `size` (positive float, default 1) sets the polygon size
  28249. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28250. * * 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`
  28251. * * 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
  28252. * * 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)`)
  28253. * * 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
  28254. * * 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
  28255. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28256. * * 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
  28257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28258. * @param name defines the name of the mesh to create
  28259. * @param options defines the options used to create the mesh
  28260. * @param scene defines the hosting scene
  28261. * @returns a new Mesh
  28262. */
  28263. static CreatePolyhedron(name: string, options: {
  28264. type?: number;
  28265. size?: number;
  28266. sizeX?: number;
  28267. sizeY?: number;
  28268. sizeZ?: number;
  28269. custom?: any;
  28270. faceUV?: Vector4[];
  28271. faceColors?: Color4[];
  28272. updatable?: boolean;
  28273. sideOrientation?: number;
  28274. }, scene: Scene): Mesh;
  28275. /**
  28276. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28277. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28278. * * 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`)
  28279. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28280. * * 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
  28281. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28282. * * 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
  28283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28284. * @param name defines the name of the mesh
  28285. * @param options defines the options used to create the mesh
  28286. * @param scene defines the hosting scene
  28287. * @returns a new Mesh
  28288. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28289. */
  28290. static CreateIcoSphere(name: string, options: {
  28291. radius?: number;
  28292. flat?: boolean;
  28293. subdivisions?: number;
  28294. sideOrientation?: number;
  28295. updatable?: boolean;
  28296. }, scene: Scene): Mesh;
  28297. /**
  28298. * Creates a decal mesh.
  28299. * Please consider using the same method from the MeshBuilder class instead.
  28300. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28301. * @param name defines the name of the mesh
  28302. * @param sourceMesh defines the mesh receiving the decal
  28303. * @param position sets the position of the decal in world coordinates
  28304. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28305. * @param size sets the decal scaling
  28306. * @param angle sets the angle to rotate the decal
  28307. * @returns a new Mesh
  28308. */
  28309. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28310. /**
  28311. * Prepare internal position array for software CPU skinning
  28312. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28313. */
  28314. setPositionsForCPUSkinning(): Float32Array;
  28315. /**
  28316. * Prepare internal normal array for software CPU skinning
  28317. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28318. */
  28319. setNormalsForCPUSkinning(): Float32Array;
  28320. /**
  28321. * Updates the vertex buffer by applying transformation from the bones
  28322. * @param skeleton defines the skeleton to apply to current mesh
  28323. * @returns the current mesh
  28324. */
  28325. applySkeleton(skeleton: Skeleton): Mesh;
  28326. /**
  28327. * 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
  28328. * @param meshes defines the list of meshes to scan
  28329. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28330. */
  28331. static MinMax(meshes: AbstractMesh[]): {
  28332. min: Vector3;
  28333. max: Vector3;
  28334. };
  28335. /**
  28336. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28337. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28338. * @returns a vector3
  28339. */
  28340. static Center(meshesOrMinMaxVector: {
  28341. min: Vector3;
  28342. max: Vector3;
  28343. } | AbstractMesh[]): Vector3;
  28344. /**
  28345. * Merge the array of meshes into a single mesh for performance reasons.
  28346. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28347. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28348. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28349. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28350. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28351. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28352. * @returns a new mesh
  28353. */
  28354. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28355. /** @hidden */
  28356. addInstance(instance: InstancedMesh): void;
  28357. /** @hidden */
  28358. removeInstance(instance: InstancedMesh): void;
  28359. }
  28360. }
  28361. declare module BABYLON {
  28362. /**
  28363. * This is the base class of all the camera used in the application.
  28364. * @see http://doc.babylonjs.com/features/cameras
  28365. */
  28366. export class Camera extends Node {
  28367. /** @hidden */
  28368. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28369. /**
  28370. * This is the default projection mode used by the cameras.
  28371. * It helps recreating a feeling of perspective and better appreciate depth.
  28372. * This is the best way to simulate real life cameras.
  28373. */
  28374. static readonly PERSPECTIVE_CAMERA: number;
  28375. /**
  28376. * This helps creating camera with an orthographic mode.
  28377. * 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.
  28378. */
  28379. static readonly ORTHOGRAPHIC_CAMERA: number;
  28380. /**
  28381. * This is the default FOV mode for perspective cameras.
  28382. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28383. */
  28384. static readonly FOVMODE_VERTICAL_FIXED: number;
  28385. /**
  28386. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28387. */
  28388. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28389. /**
  28390. * This specifies ther is no need for a camera rig.
  28391. * Basically only one eye is rendered corresponding to the camera.
  28392. */
  28393. static readonly RIG_MODE_NONE: number;
  28394. /**
  28395. * Simulates a camera Rig with one blue eye and one red eye.
  28396. * This can be use with 3d blue and red glasses.
  28397. */
  28398. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28399. /**
  28400. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28401. */
  28402. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28403. /**
  28404. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28405. */
  28406. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28407. /**
  28408. * Defines that both eyes of the camera will be rendered over under each other.
  28409. */
  28410. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28411. /**
  28412. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28413. */
  28414. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28415. /**
  28416. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28417. */
  28418. static readonly RIG_MODE_VR: number;
  28419. /**
  28420. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28421. */
  28422. static readonly RIG_MODE_WEBVR: number;
  28423. /**
  28424. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28425. */
  28426. static readonly RIG_MODE_CUSTOM: number;
  28427. /**
  28428. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28429. */
  28430. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28431. /**
  28432. * Define the input manager associated with the camera.
  28433. */
  28434. inputs: CameraInputsManager<Camera>;
  28435. /** @hidden */
  28436. _position: Vector3;
  28437. /**
  28438. * Define the current local position of the camera in the scene
  28439. */
  28440. get position(): Vector3;
  28441. set position(newPosition: Vector3);
  28442. /**
  28443. * The vector the camera should consider as up.
  28444. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28445. */
  28446. upVector: Vector3;
  28447. /**
  28448. * Define the current limit on the left side for an orthographic camera
  28449. * In scene unit
  28450. */
  28451. orthoLeft: Nullable<number>;
  28452. /**
  28453. * Define the current limit on the right side for an orthographic camera
  28454. * In scene unit
  28455. */
  28456. orthoRight: Nullable<number>;
  28457. /**
  28458. * Define the current limit on the bottom side for an orthographic camera
  28459. * In scene unit
  28460. */
  28461. orthoBottom: Nullable<number>;
  28462. /**
  28463. * Define the current limit on the top side for an orthographic camera
  28464. * In scene unit
  28465. */
  28466. orthoTop: Nullable<number>;
  28467. /**
  28468. * Field Of View is set in Radians. (default is 0.8)
  28469. */
  28470. fov: number;
  28471. /**
  28472. * Define the minimum distance the camera can see from.
  28473. * This is important to note that the depth buffer are not infinite and the closer it starts
  28474. * the more your scene might encounter depth fighting issue.
  28475. */
  28476. minZ: number;
  28477. /**
  28478. * Define the maximum distance the camera can see to.
  28479. * This is important to note that the depth buffer are not infinite and the further it end
  28480. * the more your scene might encounter depth fighting issue.
  28481. */
  28482. maxZ: number;
  28483. /**
  28484. * Define the default inertia of the camera.
  28485. * This helps giving a smooth feeling to the camera movement.
  28486. */
  28487. inertia: number;
  28488. /**
  28489. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28490. */
  28491. mode: number;
  28492. /**
  28493. * Define whether the camera is intermediate.
  28494. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28495. */
  28496. isIntermediate: boolean;
  28497. /**
  28498. * Define the viewport of the camera.
  28499. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28500. */
  28501. viewport: Viewport;
  28502. /**
  28503. * Restricts the camera to viewing objects with the same layerMask.
  28504. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28505. */
  28506. layerMask: number;
  28507. /**
  28508. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28509. */
  28510. fovMode: number;
  28511. /**
  28512. * Rig mode of the camera.
  28513. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28514. * This is normally controlled byt the camera themselves as internal use.
  28515. */
  28516. cameraRigMode: number;
  28517. /**
  28518. * Defines the distance between both "eyes" in case of a RIG
  28519. */
  28520. interaxialDistance: number;
  28521. /**
  28522. * Defines if stereoscopic rendering is done side by side or over under.
  28523. */
  28524. isStereoscopicSideBySide: boolean;
  28525. /**
  28526. * 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
  28527. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28528. * else in the scene. (Eg. security camera)
  28529. *
  28530. * 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)
  28531. */
  28532. customRenderTargets: RenderTargetTexture[];
  28533. /**
  28534. * When set, the camera will render to this render target instead of the default canvas
  28535. *
  28536. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28537. */
  28538. outputRenderTarget: Nullable<RenderTargetTexture>;
  28539. /**
  28540. * Observable triggered when the camera view matrix has changed.
  28541. */
  28542. onViewMatrixChangedObservable: Observable<Camera>;
  28543. /**
  28544. * Observable triggered when the camera Projection matrix has changed.
  28545. */
  28546. onProjectionMatrixChangedObservable: Observable<Camera>;
  28547. /**
  28548. * Observable triggered when the inputs have been processed.
  28549. */
  28550. onAfterCheckInputsObservable: Observable<Camera>;
  28551. /**
  28552. * Observable triggered when reset has been called and applied to the camera.
  28553. */
  28554. onRestoreStateObservable: Observable<Camera>;
  28555. /**
  28556. * Is this camera a part of a rig system?
  28557. */
  28558. isRigCamera: boolean;
  28559. /**
  28560. * If isRigCamera set to true this will be set with the parent camera.
  28561. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28562. */
  28563. rigParent?: Camera;
  28564. /** @hidden */
  28565. _cameraRigParams: any;
  28566. /** @hidden */
  28567. _rigCameras: Camera[];
  28568. /** @hidden */
  28569. _rigPostProcess: Nullable<PostProcess>;
  28570. protected _webvrViewMatrix: Matrix;
  28571. /** @hidden */
  28572. _skipRendering: boolean;
  28573. /** @hidden */
  28574. _projectionMatrix: Matrix;
  28575. /** @hidden */
  28576. _postProcesses: Nullable<PostProcess>[];
  28577. /** @hidden */
  28578. _activeMeshes: SmartArray<AbstractMesh>;
  28579. protected _globalPosition: Vector3;
  28580. /** @hidden */
  28581. _computedViewMatrix: Matrix;
  28582. private _doNotComputeProjectionMatrix;
  28583. private _transformMatrix;
  28584. private _frustumPlanes;
  28585. private _refreshFrustumPlanes;
  28586. private _storedFov;
  28587. private _stateStored;
  28588. /**
  28589. * Instantiates a new camera object.
  28590. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28591. * @see http://doc.babylonjs.com/features/cameras
  28592. * @param name Defines the name of the camera in the scene
  28593. * @param position Defines the position of the camera
  28594. * @param scene Defines the scene the camera belongs too
  28595. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28596. */
  28597. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28598. /**
  28599. * Store current camera state (fov, position, etc..)
  28600. * @returns the camera
  28601. */
  28602. storeState(): Camera;
  28603. /**
  28604. * Restores the camera state values if it has been stored. You must call storeState() first
  28605. */
  28606. protected _restoreStateValues(): boolean;
  28607. /**
  28608. * Restored camera state. You must call storeState() first.
  28609. * @returns true if restored and false otherwise
  28610. */
  28611. restoreState(): boolean;
  28612. /**
  28613. * Gets the class name of the camera.
  28614. * @returns the class name
  28615. */
  28616. getClassName(): string;
  28617. /** @hidden */
  28618. readonly _isCamera: boolean;
  28619. /**
  28620. * Gets a string representation of the camera useful for debug purpose.
  28621. * @param fullDetails Defines that a more verboe level of logging is required
  28622. * @returns the string representation
  28623. */
  28624. toString(fullDetails?: boolean): string;
  28625. /**
  28626. * Gets the current world space position of the camera.
  28627. */
  28628. get globalPosition(): Vector3;
  28629. /**
  28630. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28631. * @returns the active meshe list
  28632. */
  28633. getActiveMeshes(): SmartArray<AbstractMesh>;
  28634. /**
  28635. * Check whether a mesh is part of the current active mesh list of the camera
  28636. * @param mesh Defines the mesh to check
  28637. * @returns true if active, false otherwise
  28638. */
  28639. isActiveMesh(mesh: Mesh): boolean;
  28640. /**
  28641. * Is this camera ready to be used/rendered
  28642. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28643. * @return true if the camera is ready
  28644. */
  28645. isReady(completeCheck?: boolean): boolean;
  28646. /** @hidden */
  28647. _initCache(): void;
  28648. /** @hidden */
  28649. _updateCache(ignoreParentClass?: boolean): void;
  28650. /** @hidden */
  28651. _isSynchronized(): boolean;
  28652. /** @hidden */
  28653. _isSynchronizedViewMatrix(): boolean;
  28654. /** @hidden */
  28655. _isSynchronizedProjectionMatrix(): boolean;
  28656. /**
  28657. * Attach the input controls to a specific dom element to get the input from.
  28658. * @param element Defines the element the controls should be listened from
  28659. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28660. */
  28661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28662. /**
  28663. * Detach the current controls from the specified dom element.
  28664. * @param element Defines the element to stop listening the inputs from
  28665. */
  28666. detachControl(element: HTMLElement): void;
  28667. /**
  28668. * Update the camera state according to the different inputs gathered during the frame.
  28669. */
  28670. update(): void;
  28671. /** @hidden */
  28672. _checkInputs(): void;
  28673. /** @hidden */
  28674. get rigCameras(): Camera[];
  28675. /**
  28676. * Gets the post process used by the rig cameras
  28677. */
  28678. get rigPostProcess(): Nullable<PostProcess>;
  28679. /**
  28680. * Internal, gets the first post proces.
  28681. * @returns the first post process to be run on this camera.
  28682. */
  28683. _getFirstPostProcess(): Nullable<PostProcess>;
  28684. private _cascadePostProcessesToRigCams;
  28685. /**
  28686. * Attach a post process to the camera.
  28687. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28688. * @param postProcess The post process to attach to the camera
  28689. * @param insertAt The position of the post process in case several of them are in use in the scene
  28690. * @returns the position the post process has been inserted at
  28691. */
  28692. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28693. /**
  28694. * Detach a post process to the camera.
  28695. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28696. * @param postProcess The post process to detach from the camera
  28697. */
  28698. detachPostProcess(postProcess: PostProcess): void;
  28699. /**
  28700. * Gets the current world matrix of the camera
  28701. */
  28702. getWorldMatrix(): Matrix;
  28703. /** @hidden */
  28704. _getViewMatrix(): Matrix;
  28705. /**
  28706. * Gets the current view matrix of the camera.
  28707. * @param force forces the camera to recompute the matrix without looking at the cached state
  28708. * @returns the view matrix
  28709. */
  28710. getViewMatrix(force?: boolean): Matrix;
  28711. /**
  28712. * Freeze the projection matrix.
  28713. * It will prevent the cache check of the camera projection compute and can speed up perf
  28714. * if no parameter of the camera are meant to change
  28715. * @param projection Defines manually a projection if necessary
  28716. */
  28717. freezeProjectionMatrix(projection?: Matrix): void;
  28718. /**
  28719. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28720. */
  28721. unfreezeProjectionMatrix(): void;
  28722. /**
  28723. * Gets the current projection matrix of the camera.
  28724. * @param force forces the camera to recompute the matrix without looking at the cached state
  28725. * @returns the projection matrix
  28726. */
  28727. getProjectionMatrix(force?: boolean): Matrix;
  28728. /**
  28729. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28730. * @returns a Matrix
  28731. */
  28732. getTransformationMatrix(): Matrix;
  28733. private _updateFrustumPlanes;
  28734. /**
  28735. * Checks if a cullable object (mesh...) is in the camera frustum
  28736. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28737. * @param target The object to check
  28738. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28739. * @returns true if the object is in frustum otherwise false
  28740. */
  28741. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28742. /**
  28743. * Checks if a cullable object (mesh...) is in the camera frustum
  28744. * Unlike isInFrustum this cheks the full bounding box
  28745. * @param target The object to check
  28746. * @returns true if the object is in frustum otherwise false
  28747. */
  28748. isCompletelyInFrustum(target: ICullable): boolean;
  28749. /**
  28750. * Gets a ray in the forward direction from the camera.
  28751. * @param length Defines the length of the ray to create
  28752. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28753. * @param origin Defines the start point of the ray which defaults to the camera position
  28754. * @returns the forward ray
  28755. */
  28756. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28757. /**
  28758. * Releases resources associated with this node.
  28759. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28760. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28761. */
  28762. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28763. /** @hidden */
  28764. _isLeftCamera: boolean;
  28765. /**
  28766. * Gets the left camera of a rig setup in case of Rigged Camera
  28767. */
  28768. get isLeftCamera(): boolean;
  28769. /** @hidden */
  28770. _isRightCamera: boolean;
  28771. /**
  28772. * Gets the right camera of a rig setup in case of Rigged Camera
  28773. */
  28774. get isRightCamera(): boolean;
  28775. /**
  28776. * Gets the left camera of a rig setup in case of Rigged Camera
  28777. */
  28778. get leftCamera(): Nullable<FreeCamera>;
  28779. /**
  28780. * Gets the right camera of a rig setup in case of Rigged Camera
  28781. */
  28782. get rightCamera(): Nullable<FreeCamera>;
  28783. /**
  28784. * Gets the left camera target of a rig setup in case of Rigged Camera
  28785. * @returns the target position
  28786. */
  28787. getLeftTarget(): Nullable<Vector3>;
  28788. /**
  28789. * Gets the right camera target of a rig setup in case of Rigged Camera
  28790. * @returns the target position
  28791. */
  28792. getRightTarget(): Nullable<Vector3>;
  28793. /**
  28794. * @hidden
  28795. */
  28796. setCameraRigMode(mode: number, rigParams: any): void;
  28797. /** @hidden */
  28798. static _setStereoscopicRigMode(camera: Camera): void;
  28799. /** @hidden */
  28800. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28801. /** @hidden */
  28802. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28803. /** @hidden */
  28804. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28805. /** @hidden */
  28806. _getVRProjectionMatrix(): Matrix;
  28807. protected _updateCameraRotationMatrix(): void;
  28808. protected _updateWebVRCameraRotationMatrix(): void;
  28809. /**
  28810. * This function MUST be overwritten by the different WebVR cameras available.
  28811. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28812. * @hidden
  28813. */
  28814. _getWebVRProjectionMatrix(): Matrix;
  28815. /**
  28816. * This function MUST be overwritten by the different WebVR cameras available.
  28817. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28818. * @hidden
  28819. */
  28820. _getWebVRViewMatrix(): Matrix;
  28821. /** @hidden */
  28822. setCameraRigParameter(name: string, value: any): void;
  28823. /**
  28824. * needs to be overridden by children so sub has required properties to be copied
  28825. * @hidden
  28826. */
  28827. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28828. /**
  28829. * May need to be overridden by children
  28830. * @hidden
  28831. */
  28832. _updateRigCameras(): void;
  28833. /** @hidden */
  28834. _setupInputs(): void;
  28835. /**
  28836. * Serialiaze the camera setup to a json represention
  28837. * @returns the JSON representation
  28838. */
  28839. serialize(): any;
  28840. /**
  28841. * Clones the current camera.
  28842. * @param name The cloned camera name
  28843. * @returns the cloned camera
  28844. */
  28845. clone(name: string): Camera;
  28846. /**
  28847. * Gets the direction of the camera relative to a given local axis.
  28848. * @param localAxis Defines the reference axis to provide a relative direction.
  28849. * @return the direction
  28850. */
  28851. getDirection(localAxis: Vector3): Vector3;
  28852. /**
  28853. * Returns the current camera absolute rotation
  28854. */
  28855. get absoluteRotation(): Quaternion;
  28856. /**
  28857. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28858. * @param localAxis Defines the reference axis to provide a relative direction.
  28859. * @param result Defines the vector to store the result in
  28860. */
  28861. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28862. /**
  28863. * Gets a camera constructor for a given camera type
  28864. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28865. * @param name The name of the camera the result will be able to instantiate
  28866. * @param scene The scene the result will construct the camera in
  28867. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28868. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28869. * @returns a factory method to construc the camera
  28870. */
  28871. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28872. /**
  28873. * Compute the world matrix of the camera.
  28874. * @returns the camera world matrix
  28875. */
  28876. computeWorldMatrix(): Matrix;
  28877. /**
  28878. * Parse a JSON and creates the camera from the parsed information
  28879. * @param parsedCamera The JSON to parse
  28880. * @param scene The scene to instantiate the camera in
  28881. * @returns the newly constructed camera
  28882. */
  28883. static Parse(parsedCamera: any, scene: Scene): Camera;
  28884. }
  28885. }
  28886. declare module BABYLON {
  28887. /**
  28888. * Class containing static functions to help procedurally build meshes
  28889. */
  28890. export class DiscBuilder {
  28891. /**
  28892. * Creates a plane polygonal mesh. By default, this is a disc
  28893. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28894. * * 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
  28895. * * 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
  28896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28897. * * 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
  28898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28899. * @param name defines the name of the mesh
  28900. * @param options defines the options used to create the mesh
  28901. * @param scene defines the hosting scene
  28902. * @returns the plane polygonal mesh
  28903. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28904. */
  28905. static CreateDisc(name: string, options: {
  28906. radius?: number;
  28907. tessellation?: number;
  28908. arc?: number;
  28909. updatable?: boolean;
  28910. sideOrientation?: number;
  28911. frontUVs?: Vector4;
  28912. backUVs?: Vector4;
  28913. }, scene?: Nullable<Scene>): Mesh;
  28914. }
  28915. }
  28916. declare module BABYLON {
  28917. /**
  28918. * Options to be used when creating a FresnelParameters.
  28919. */
  28920. export type IFresnelParametersCreationOptions = {
  28921. /**
  28922. * Define the color used on edges (grazing angle)
  28923. */
  28924. leftColor?: Color3;
  28925. /**
  28926. * Define the color used on center
  28927. */
  28928. rightColor?: Color3;
  28929. /**
  28930. * Define bias applied to computed fresnel term
  28931. */
  28932. bias?: number;
  28933. /**
  28934. * Defined the power exponent applied to fresnel term
  28935. */
  28936. power?: number;
  28937. /**
  28938. * Define if the fresnel effect is enable or not.
  28939. */
  28940. isEnabled?: boolean;
  28941. };
  28942. /**
  28943. * Serialized format for FresnelParameters.
  28944. */
  28945. export type IFresnelParametersSerialized = {
  28946. /**
  28947. * Define the color used on edges (grazing angle) [as an array]
  28948. */
  28949. leftColor: number[];
  28950. /**
  28951. * Define the color used on center [as an array]
  28952. */
  28953. rightColor: number[];
  28954. /**
  28955. * Define bias applied to computed fresnel term
  28956. */
  28957. bias: number;
  28958. /**
  28959. * Defined the power exponent applied to fresnel term
  28960. */
  28961. power?: number;
  28962. /**
  28963. * Define if the fresnel effect is enable or not.
  28964. */
  28965. isEnabled: boolean;
  28966. };
  28967. /**
  28968. * This represents all the required information to add a fresnel effect on a material:
  28969. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28970. */
  28971. export class FresnelParameters {
  28972. private _isEnabled;
  28973. /**
  28974. * Define if the fresnel effect is enable or not.
  28975. */
  28976. get isEnabled(): boolean;
  28977. set isEnabled(value: boolean);
  28978. /**
  28979. * Define the color used on edges (grazing angle)
  28980. */
  28981. leftColor: Color3;
  28982. /**
  28983. * Define the color used on center
  28984. */
  28985. rightColor: Color3;
  28986. /**
  28987. * Define bias applied to computed fresnel term
  28988. */
  28989. bias: number;
  28990. /**
  28991. * Defined the power exponent applied to fresnel term
  28992. */
  28993. power: number;
  28994. /**
  28995. * Creates a new FresnelParameters object.
  28996. *
  28997. * @param options provide your own settings to optionally to override defaults
  28998. */
  28999. constructor(options?: IFresnelParametersCreationOptions);
  29000. /**
  29001. * Clones the current fresnel and its valuues
  29002. * @returns a clone fresnel configuration
  29003. */
  29004. clone(): FresnelParameters;
  29005. /**
  29006. * Determines equality between FresnelParameters objects
  29007. * @param otherFresnelParameters defines the second operand
  29008. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29009. */
  29010. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29011. /**
  29012. * Serializes the current fresnel parameters to a JSON representation.
  29013. * @return the JSON serialization
  29014. */
  29015. serialize(): IFresnelParametersSerialized;
  29016. /**
  29017. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29018. * @param parsedFresnelParameters Define the JSON representation
  29019. * @returns the parsed parameters
  29020. */
  29021. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29022. }
  29023. }
  29024. declare module BABYLON {
  29025. /**
  29026. * This groups all the flags used to control the materials channel.
  29027. */
  29028. export class MaterialFlags {
  29029. private static _DiffuseTextureEnabled;
  29030. /**
  29031. * Are diffuse textures enabled in the application.
  29032. */
  29033. static get DiffuseTextureEnabled(): boolean;
  29034. static set DiffuseTextureEnabled(value: boolean);
  29035. private static _AmbientTextureEnabled;
  29036. /**
  29037. * Are ambient textures enabled in the application.
  29038. */
  29039. static get AmbientTextureEnabled(): boolean;
  29040. static set AmbientTextureEnabled(value: boolean);
  29041. private static _OpacityTextureEnabled;
  29042. /**
  29043. * Are opacity textures enabled in the application.
  29044. */
  29045. static get OpacityTextureEnabled(): boolean;
  29046. static set OpacityTextureEnabled(value: boolean);
  29047. private static _ReflectionTextureEnabled;
  29048. /**
  29049. * Are reflection textures enabled in the application.
  29050. */
  29051. static get ReflectionTextureEnabled(): boolean;
  29052. static set ReflectionTextureEnabled(value: boolean);
  29053. private static _EmissiveTextureEnabled;
  29054. /**
  29055. * Are emissive textures enabled in the application.
  29056. */
  29057. static get EmissiveTextureEnabled(): boolean;
  29058. static set EmissiveTextureEnabled(value: boolean);
  29059. private static _SpecularTextureEnabled;
  29060. /**
  29061. * Are specular textures enabled in the application.
  29062. */
  29063. static get SpecularTextureEnabled(): boolean;
  29064. static set SpecularTextureEnabled(value: boolean);
  29065. private static _BumpTextureEnabled;
  29066. /**
  29067. * Are bump textures enabled in the application.
  29068. */
  29069. static get BumpTextureEnabled(): boolean;
  29070. static set BumpTextureEnabled(value: boolean);
  29071. private static _LightmapTextureEnabled;
  29072. /**
  29073. * Are lightmap textures enabled in the application.
  29074. */
  29075. static get LightmapTextureEnabled(): boolean;
  29076. static set LightmapTextureEnabled(value: boolean);
  29077. private static _RefractionTextureEnabled;
  29078. /**
  29079. * Are refraction textures enabled in the application.
  29080. */
  29081. static get RefractionTextureEnabled(): boolean;
  29082. static set RefractionTextureEnabled(value: boolean);
  29083. private static _ColorGradingTextureEnabled;
  29084. /**
  29085. * Are color grading textures enabled in the application.
  29086. */
  29087. static get ColorGradingTextureEnabled(): boolean;
  29088. static set ColorGradingTextureEnabled(value: boolean);
  29089. private static _FresnelEnabled;
  29090. /**
  29091. * Are fresnels enabled in the application.
  29092. */
  29093. static get FresnelEnabled(): boolean;
  29094. static set FresnelEnabled(value: boolean);
  29095. private static _ClearCoatTextureEnabled;
  29096. /**
  29097. * Are clear coat textures enabled in the application.
  29098. */
  29099. static get ClearCoatTextureEnabled(): boolean;
  29100. static set ClearCoatTextureEnabled(value: boolean);
  29101. private static _ClearCoatBumpTextureEnabled;
  29102. /**
  29103. * Are clear coat bump textures enabled in the application.
  29104. */
  29105. static get ClearCoatBumpTextureEnabled(): boolean;
  29106. static set ClearCoatBumpTextureEnabled(value: boolean);
  29107. private static _ClearCoatTintTextureEnabled;
  29108. /**
  29109. * Are clear coat tint textures enabled in the application.
  29110. */
  29111. static get ClearCoatTintTextureEnabled(): boolean;
  29112. static set ClearCoatTintTextureEnabled(value: boolean);
  29113. private static _SheenTextureEnabled;
  29114. /**
  29115. * Are sheen textures enabled in the application.
  29116. */
  29117. static get SheenTextureEnabled(): boolean;
  29118. static set SheenTextureEnabled(value: boolean);
  29119. private static _AnisotropicTextureEnabled;
  29120. /**
  29121. * Are anisotropic textures enabled in the application.
  29122. */
  29123. static get AnisotropicTextureEnabled(): boolean;
  29124. static set AnisotropicTextureEnabled(value: boolean);
  29125. private static _ThicknessTextureEnabled;
  29126. /**
  29127. * Are thickness textures enabled in the application.
  29128. */
  29129. static get ThicknessTextureEnabled(): boolean;
  29130. static set ThicknessTextureEnabled(value: boolean);
  29131. }
  29132. }
  29133. declare module BABYLON {
  29134. /** @hidden */
  29135. export var defaultFragmentDeclaration: {
  29136. name: string;
  29137. shader: string;
  29138. };
  29139. }
  29140. declare module BABYLON {
  29141. /** @hidden */
  29142. export var defaultUboDeclaration: {
  29143. name: string;
  29144. shader: string;
  29145. };
  29146. }
  29147. declare module BABYLON {
  29148. /** @hidden */
  29149. export var lightFragmentDeclaration: {
  29150. name: string;
  29151. shader: string;
  29152. };
  29153. }
  29154. declare module BABYLON {
  29155. /** @hidden */
  29156. export var lightUboDeclaration: {
  29157. name: string;
  29158. shader: string;
  29159. };
  29160. }
  29161. declare module BABYLON {
  29162. /** @hidden */
  29163. export var lightsFragmentFunctions: {
  29164. name: string;
  29165. shader: string;
  29166. };
  29167. }
  29168. declare module BABYLON {
  29169. /** @hidden */
  29170. export var shadowsFragmentFunctions: {
  29171. name: string;
  29172. shader: string;
  29173. };
  29174. }
  29175. declare module BABYLON {
  29176. /** @hidden */
  29177. export var fresnelFunction: {
  29178. name: string;
  29179. shader: string;
  29180. };
  29181. }
  29182. declare module BABYLON {
  29183. /** @hidden */
  29184. export var bumpFragmentMainFunctions: {
  29185. name: string;
  29186. shader: string;
  29187. };
  29188. }
  29189. declare module BABYLON {
  29190. /** @hidden */
  29191. export var bumpFragmentFunctions: {
  29192. name: string;
  29193. shader: string;
  29194. };
  29195. }
  29196. declare module BABYLON {
  29197. /** @hidden */
  29198. export var logDepthDeclaration: {
  29199. name: string;
  29200. shader: string;
  29201. };
  29202. }
  29203. declare module BABYLON {
  29204. /** @hidden */
  29205. export var bumpFragment: {
  29206. name: string;
  29207. shader: string;
  29208. };
  29209. }
  29210. declare module BABYLON {
  29211. /** @hidden */
  29212. export var depthPrePass: {
  29213. name: string;
  29214. shader: string;
  29215. };
  29216. }
  29217. declare module BABYLON {
  29218. /** @hidden */
  29219. export var lightFragment: {
  29220. name: string;
  29221. shader: string;
  29222. };
  29223. }
  29224. declare module BABYLON {
  29225. /** @hidden */
  29226. export var logDepthFragment: {
  29227. name: string;
  29228. shader: string;
  29229. };
  29230. }
  29231. declare module BABYLON {
  29232. /** @hidden */
  29233. export var defaultPixelShader: {
  29234. name: string;
  29235. shader: string;
  29236. };
  29237. }
  29238. declare module BABYLON {
  29239. /** @hidden */
  29240. export var defaultVertexDeclaration: {
  29241. name: string;
  29242. shader: string;
  29243. };
  29244. }
  29245. declare module BABYLON {
  29246. /** @hidden */
  29247. export var bumpVertexDeclaration: {
  29248. name: string;
  29249. shader: string;
  29250. };
  29251. }
  29252. declare module BABYLON {
  29253. /** @hidden */
  29254. export var bumpVertex: {
  29255. name: string;
  29256. shader: string;
  29257. };
  29258. }
  29259. declare module BABYLON {
  29260. /** @hidden */
  29261. export var fogVertex: {
  29262. name: string;
  29263. shader: string;
  29264. };
  29265. }
  29266. declare module BABYLON {
  29267. /** @hidden */
  29268. export var shadowsVertex: {
  29269. name: string;
  29270. shader: string;
  29271. };
  29272. }
  29273. declare module BABYLON {
  29274. /** @hidden */
  29275. export var pointCloudVertex: {
  29276. name: string;
  29277. shader: string;
  29278. };
  29279. }
  29280. declare module BABYLON {
  29281. /** @hidden */
  29282. export var logDepthVertex: {
  29283. name: string;
  29284. shader: string;
  29285. };
  29286. }
  29287. declare module BABYLON {
  29288. /** @hidden */
  29289. export var defaultVertexShader: {
  29290. name: string;
  29291. shader: string;
  29292. };
  29293. }
  29294. declare module BABYLON {
  29295. /** @hidden */
  29296. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29297. MAINUV1: boolean;
  29298. MAINUV2: boolean;
  29299. DIFFUSE: boolean;
  29300. DIFFUSEDIRECTUV: number;
  29301. AMBIENT: boolean;
  29302. AMBIENTDIRECTUV: number;
  29303. OPACITY: boolean;
  29304. OPACITYDIRECTUV: number;
  29305. OPACITYRGB: boolean;
  29306. REFLECTION: boolean;
  29307. EMISSIVE: boolean;
  29308. EMISSIVEDIRECTUV: number;
  29309. SPECULAR: boolean;
  29310. SPECULARDIRECTUV: number;
  29311. BUMP: boolean;
  29312. BUMPDIRECTUV: number;
  29313. PARALLAX: boolean;
  29314. PARALLAXOCCLUSION: boolean;
  29315. SPECULAROVERALPHA: boolean;
  29316. CLIPPLANE: boolean;
  29317. CLIPPLANE2: boolean;
  29318. CLIPPLANE3: boolean;
  29319. CLIPPLANE4: boolean;
  29320. CLIPPLANE5: boolean;
  29321. CLIPPLANE6: boolean;
  29322. ALPHATEST: boolean;
  29323. DEPTHPREPASS: boolean;
  29324. ALPHAFROMDIFFUSE: boolean;
  29325. POINTSIZE: boolean;
  29326. FOG: boolean;
  29327. SPECULARTERM: boolean;
  29328. DIFFUSEFRESNEL: boolean;
  29329. OPACITYFRESNEL: boolean;
  29330. REFLECTIONFRESNEL: boolean;
  29331. REFRACTIONFRESNEL: boolean;
  29332. EMISSIVEFRESNEL: boolean;
  29333. FRESNEL: boolean;
  29334. NORMAL: boolean;
  29335. UV1: boolean;
  29336. UV2: boolean;
  29337. VERTEXCOLOR: boolean;
  29338. VERTEXALPHA: boolean;
  29339. NUM_BONE_INFLUENCERS: number;
  29340. BonesPerMesh: number;
  29341. BONETEXTURE: boolean;
  29342. INSTANCES: boolean;
  29343. THIN_INSTANCES: boolean;
  29344. GLOSSINESS: boolean;
  29345. ROUGHNESS: boolean;
  29346. EMISSIVEASILLUMINATION: boolean;
  29347. LINKEMISSIVEWITHDIFFUSE: boolean;
  29348. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29349. LIGHTMAP: boolean;
  29350. LIGHTMAPDIRECTUV: number;
  29351. OBJECTSPACE_NORMALMAP: boolean;
  29352. USELIGHTMAPASSHADOWMAP: boolean;
  29353. REFLECTIONMAP_3D: boolean;
  29354. REFLECTIONMAP_SPHERICAL: boolean;
  29355. REFLECTIONMAP_PLANAR: boolean;
  29356. REFLECTIONMAP_CUBIC: boolean;
  29357. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29358. REFLECTIONMAP_PROJECTION: boolean;
  29359. REFLECTIONMAP_SKYBOX: boolean;
  29360. REFLECTIONMAP_EXPLICIT: boolean;
  29361. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29362. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29363. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29364. INVERTCUBICMAP: boolean;
  29365. LOGARITHMICDEPTH: boolean;
  29366. REFRACTION: boolean;
  29367. REFRACTIONMAP_3D: boolean;
  29368. REFLECTIONOVERALPHA: boolean;
  29369. TWOSIDEDLIGHTING: boolean;
  29370. SHADOWFLOAT: boolean;
  29371. MORPHTARGETS: boolean;
  29372. MORPHTARGETS_NORMAL: boolean;
  29373. MORPHTARGETS_TANGENT: boolean;
  29374. MORPHTARGETS_UV: boolean;
  29375. NUM_MORPH_INFLUENCERS: number;
  29376. NONUNIFORMSCALING: boolean;
  29377. PREMULTIPLYALPHA: boolean;
  29378. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29379. ALPHABLEND: boolean;
  29380. RGBDLIGHTMAP: boolean;
  29381. RGBDREFLECTION: boolean;
  29382. RGBDREFRACTION: boolean;
  29383. IMAGEPROCESSING: boolean;
  29384. VIGNETTE: boolean;
  29385. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29386. VIGNETTEBLENDMODEOPAQUE: boolean;
  29387. TONEMAPPING: boolean;
  29388. TONEMAPPING_ACES: boolean;
  29389. CONTRAST: boolean;
  29390. COLORCURVES: boolean;
  29391. COLORGRADING: boolean;
  29392. COLORGRADING3D: boolean;
  29393. SAMPLER3DGREENDEPTH: boolean;
  29394. SAMPLER3DBGRMAP: boolean;
  29395. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29396. MULTIVIEW: boolean;
  29397. /**
  29398. * If the reflection texture on this material is in linear color space
  29399. * @hidden
  29400. */
  29401. IS_REFLECTION_LINEAR: boolean;
  29402. /**
  29403. * If the refraction texture on this material is in linear color space
  29404. * @hidden
  29405. */
  29406. IS_REFRACTION_LINEAR: boolean;
  29407. EXPOSURE: boolean;
  29408. constructor();
  29409. setReflectionMode(modeToEnable: string): void;
  29410. }
  29411. /**
  29412. * This is the default material used in Babylon. It is the best trade off between quality
  29413. * and performances.
  29414. * @see http://doc.babylonjs.com/babylon101/materials
  29415. */
  29416. export class StandardMaterial extends PushMaterial {
  29417. private _diffuseTexture;
  29418. /**
  29419. * The basic texture of the material as viewed under a light.
  29420. */
  29421. diffuseTexture: Nullable<BaseTexture>;
  29422. private _ambientTexture;
  29423. /**
  29424. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29425. */
  29426. ambientTexture: Nullable<BaseTexture>;
  29427. private _opacityTexture;
  29428. /**
  29429. * Define the transparency of the material from a texture.
  29430. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29431. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29432. */
  29433. opacityTexture: Nullable<BaseTexture>;
  29434. private _reflectionTexture;
  29435. /**
  29436. * Define the texture used to display the reflection.
  29437. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29438. */
  29439. reflectionTexture: Nullable<BaseTexture>;
  29440. private _emissiveTexture;
  29441. /**
  29442. * Define texture of the material as if self lit.
  29443. * This will be mixed in the final result even in the absence of light.
  29444. */
  29445. emissiveTexture: Nullable<BaseTexture>;
  29446. private _specularTexture;
  29447. /**
  29448. * Define how the color and intensity of the highlight given by the light in the material.
  29449. */
  29450. specularTexture: Nullable<BaseTexture>;
  29451. private _bumpTexture;
  29452. /**
  29453. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29454. * 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.
  29455. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29456. */
  29457. bumpTexture: Nullable<BaseTexture>;
  29458. private _lightmapTexture;
  29459. /**
  29460. * Complex lighting can be computationally expensive to compute at runtime.
  29461. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29462. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29463. */
  29464. lightmapTexture: Nullable<BaseTexture>;
  29465. private _refractionTexture;
  29466. /**
  29467. * Define the texture used to display the refraction.
  29468. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29469. */
  29470. refractionTexture: Nullable<BaseTexture>;
  29471. /**
  29472. * The color of the material lit by the environmental background lighting.
  29473. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29474. */
  29475. ambientColor: Color3;
  29476. /**
  29477. * The basic color of the material as viewed under a light.
  29478. */
  29479. diffuseColor: Color3;
  29480. /**
  29481. * Define how the color and intensity of the highlight given by the light in the material.
  29482. */
  29483. specularColor: Color3;
  29484. /**
  29485. * Define the color of the material as if self lit.
  29486. * This will be mixed in the final result even in the absence of light.
  29487. */
  29488. emissiveColor: Color3;
  29489. /**
  29490. * Defines how sharp are the highlights in the material.
  29491. * The bigger the value the sharper giving a more glossy feeling to the result.
  29492. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29493. */
  29494. specularPower: number;
  29495. private _useAlphaFromDiffuseTexture;
  29496. /**
  29497. * Does the transparency come from the diffuse texture alpha channel.
  29498. */
  29499. useAlphaFromDiffuseTexture: boolean;
  29500. private _useEmissiveAsIllumination;
  29501. /**
  29502. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29503. */
  29504. useEmissiveAsIllumination: boolean;
  29505. private _linkEmissiveWithDiffuse;
  29506. /**
  29507. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29508. * the emissive level when the final color is close to one.
  29509. */
  29510. linkEmissiveWithDiffuse: boolean;
  29511. private _useSpecularOverAlpha;
  29512. /**
  29513. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29514. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29515. */
  29516. useSpecularOverAlpha: boolean;
  29517. private _useReflectionOverAlpha;
  29518. /**
  29519. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29520. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29521. */
  29522. useReflectionOverAlpha: boolean;
  29523. private _disableLighting;
  29524. /**
  29525. * Does lights from the scene impacts this material.
  29526. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29527. */
  29528. disableLighting: boolean;
  29529. private _useObjectSpaceNormalMap;
  29530. /**
  29531. * Allows using an object space normal map (instead of tangent space).
  29532. */
  29533. useObjectSpaceNormalMap: boolean;
  29534. private _useParallax;
  29535. /**
  29536. * Is parallax enabled or not.
  29537. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29538. */
  29539. useParallax: boolean;
  29540. private _useParallaxOcclusion;
  29541. /**
  29542. * Is parallax occlusion enabled or not.
  29543. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29544. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29545. */
  29546. useParallaxOcclusion: boolean;
  29547. /**
  29548. * 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.
  29549. */
  29550. parallaxScaleBias: number;
  29551. private _roughness;
  29552. /**
  29553. * Helps to define how blurry the reflections should appears in the material.
  29554. */
  29555. roughness: number;
  29556. /**
  29557. * In case of refraction, define the value of the index of refraction.
  29558. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29559. */
  29560. indexOfRefraction: number;
  29561. /**
  29562. * Invert the refraction texture alongside the y axis.
  29563. * It can be useful with procedural textures or probe for instance.
  29564. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29565. */
  29566. invertRefractionY: boolean;
  29567. /**
  29568. * Defines the alpha limits in alpha test mode.
  29569. */
  29570. alphaCutOff: number;
  29571. private _useLightmapAsShadowmap;
  29572. /**
  29573. * In case of light mapping, define whether the map contains light or shadow informations.
  29574. */
  29575. useLightmapAsShadowmap: boolean;
  29576. private _diffuseFresnelParameters;
  29577. /**
  29578. * Define the diffuse fresnel parameters of the material.
  29579. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29580. */
  29581. diffuseFresnelParameters: FresnelParameters;
  29582. private _opacityFresnelParameters;
  29583. /**
  29584. * Define the opacity fresnel parameters of the material.
  29585. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29586. */
  29587. opacityFresnelParameters: FresnelParameters;
  29588. private _reflectionFresnelParameters;
  29589. /**
  29590. * Define the reflection fresnel parameters of the material.
  29591. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29592. */
  29593. reflectionFresnelParameters: FresnelParameters;
  29594. private _refractionFresnelParameters;
  29595. /**
  29596. * Define the refraction fresnel parameters of the material.
  29597. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29598. */
  29599. refractionFresnelParameters: FresnelParameters;
  29600. private _emissiveFresnelParameters;
  29601. /**
  29602. * Define the emissive fresnel parameters of the material.
  29603. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29604. */
  29605. emissiveFresnelParameters: FresnelParameters;
  29606. private _useReflectionFresnelFromSpecular;
  29607. /**
  29608. * If true automatically deducts the fresnels values from the material specularity.
  29609. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29610. */
  29611. useReflectionFresnelFromSpecular: boolean;
  29612. private _useGlossinessFromSpecularMapAlpha;
  29613. /**
  29614. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29615. */
  29616. useGlossinessFromSpecularMapAlpha: boolean;
  29617. private _maxSimultaneousLights;
  29618. /**
  29619. * Defines the maximum number of lights that can be used in the material
  29620. */
  29621. maxSimultaneousLights: number;
  29622. private _invertNormalMapX;
  29623. /**
  29624. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29625. */
  29626. invertNormalMapX: boolean;
  29627. private _invertNormalMapY;
  29628. /**
  29629. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29630. */
  29631. invertNormalMapY: boolean;
  29632. private _twoSidedLighting;
  29633. /**
  29634. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29635. */
  29636. twoSidedLighting: boolean;
  29637. /**
  29638. * Default configuration related to image processing available in the standard Material.
  29639. */
  29640. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29641. /**
  29642. * Gets the image processing configuration used either in this material.
  29643. */
  29644. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29645. /**
  29646. * Sets the Default image processing configuration used either in the this material.
  29647. *
  29648. * If sets to null, the scene one is in use.
  29649. */
  29650. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29651. /**
  29652. * Keep track of the image processing observer to allow dispose and replace.
  29653. */
  29654. private _imageProcessingObserver;
  29655. /**
  29656. * Attaches a new image processing configuration to the Standard Material.
  29657. * @param configuration
  29658. */
  29659. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29660. /**
  29661. * Gets wether the color curves effect is enabled.
  29662. */
  29663. get cameraColorCurvesEnabled(): boolean;
  29664. /**
  29665. * Sets wether the color curves effect is enabled.
  29666. */
  29667. set cameraColorCurvesEnabled(value: boolean);
  29668. /**
  29669. * Gets wether the color grading effect is enabled.
  29670. */
  29671. get cameraColorGradingEnabled(): boolean;
  29672. /**
  29673. * Gets wether the color grading effect is enabled.
  29674. */
  29675. set cameraColorGradingEnabled(value: boolean);
  29676. /**
  29677. * Gets wether tonemapping is enabled or not.
  29678. */
  29679. get cameraToneMappingEnabled(): boolean;
  29680. /**
  29681. * Sets wether tonemapping is enabled or not
  29682. */
  29683. set cameraToneMappingEnabled(value: boolean);
  29684. /**
  29685. * The camera exposure used on this material.
  29686. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29687. * This corresponds to a photographic exposure.
  29688. */
  29689. get cameraExposure(): number;
  29690. /**
  29691. * The camera exposure used on this material.
  29692. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29693. * This corresponds to a photographic exposure.
  29694. */
  29695. set cameraExposure(value: number);
  29696. /**
  29697. * Gets The camera contrast used on this material.
  29698. */
  29699. get cameraContrast(): number;
  29700. /**
  29701. * Sets The camera contrast used on this material.
  29702. */
  29703. set cameraContrast(value: number);
  29704. /**
  29705. * Gets the Color Grading 2D Lookup Texture.
  29706. */
  29707. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29708. /**
  29709. * Sets the Color Grading 2D Lookup Texture.
  29710. */
  29711. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29712. /**
  29713. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29714. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29715. * 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;
  29716. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29717. */
  29718. get cameraColorCurves(): Nullable<ColorCurves>;
  29719. /**
  29720. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29721. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29722. * 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;
  29723. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29724. */
  29725. set cameraColorCurves(value: Nullable<ColorCurves>);
  29726. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29727. protected _worldViewProjectionMatrix: Matrix;
  29728. protected _globalAmbientColor: Color3;
  29729. protected _useLogarithmicDepth: boolean;
  29730. protected _rebuildInParallel: boolean;
  29731. /**
  29732. * Instantiates a new standard material.
  29733. * This is the default material used in Babylon. It is the best trade off between quality
  29734. * and performances.
  29735. * @see http://doc.babylonjs.com/babylon101/materials
  29736. * @param name Define the name of the material in the scene
  29737. * @param scene Define the scene the material belong to
  29738. */
  29739. constructor(name: string, scene: Scene);
  29740. /**
  29741. * Gets a boolean indicating that current material needs to register RTT
  29742. */
  29743. get hasRenderTargetTextures(): boolean;
  29744. /**
  29745. * Gets the current class name of the material e.g. "StandardMaterial"
  29746. * Mainly use in serialization.
  29747. * @returns the class name
  29748. */
  29749. getClassName(): string;
  29750. /**
  29751. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29752. * You can try switching to logarithmic depth.
  29753. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29754. */
  29755. get useLogarithmicDepth(): boolean;
  29756. set useLogarithmicDepth(value: boolean);
  29757. /**
  29758. * Specifies if the material will require alpha blending
  29759. * @returns a boolean specifying if alpha blending is needed
  29760. */
  29761. needAlphaBlending(): boolean;
  29762. /**
  29763. * Specifies if this material should be rendered in alpha test mode
  29764. * @returns a boolean specifying if an alpha test is needed.
  29765. */
  29766. needAlphaTesting(): boolean;
  29767. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29768. /**
  29769. * Get the texture used for alpha test purpose.
  29770. * @returns the diffuse texture in case of the standard material.
  29771. */
  29772. getAlphaTestTexture(): Nullable<BaseTexture>;
  29773. /**
  29774. * Get if the submesh is ready to be used and all its information available.
  29775. * Child classes can use it to update shaders
  29776. * @param mesh defines the mesh to check
  29777. * @param subMesh defines which submesh to check
  29778. * @param useInstances specifies that instances should be used
  29779. * @returns a boolean indicating that the submesh is ready or not
  29780. */
  29781. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29782. /**
  29783. * Builds the material UBO layouts.
  29784. * Used internally during the effect preparation.
  29785. */
  29786. buildUniformLayout(): void;
  29787. /**
  29788. * Unbinds the material from the mesh
  29789. */
  29790. unbind(): void;
  29791. /**
  29792. * Binds the submesh to this material by preparing the effect and shader to draw
  29793. * @param world defines the world transformation matrix
  29794. * @param mesh defines the mesh containing the submesh
  29795. * @param subMesh defines the submesh to bind the material to
  29796. */
  29797. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29798. /**
  29799. * Get the list of animatables in the material.
  29800. * @returns the list of animatables object used in the material
  29801. */
  29802. getAnimatables(): IAnimatable[];
  29803. /**
  29804. * Gets the active textures from the material
  29805. * @returns an array of textures
  29806. */
  29807. getActiveTextures(): BaseTexture[];
  29808. /**
  29809. * Specifies if the material uses a texture
  29810. * @param texture defines the texture to check against the material
  29811. * @returns a boolean specifying if the material uses the texture
  29812. */
  29813. hasTexture(texture: BaseTexture): boolean;
  29814. /**
  29815. * Disposes the material
  29816. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29817. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29818. */
  29819. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  29820. /**
  29821. * Makes a duplicate of the material, and gives it a new name
  29822. * @param name defines the new name for the duplicated material
  29823. * @returns the cloned material
  29824. */
  29825. clone(name: string): StandardMaterial;
  29826. /**
  29827. * Serializes this material in a JSON representation
  29828. * @returns the serialized material object
  29829. */
  29830. serialize(): any;
  29831. /**
  29832. * Creates a standard material from parsed material data
  29833. * @param source defines the JSON representation of the material
  29834. * @param scene defines the hosting scene
  29835. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29836. * @returns a new standard material
  29837. */
  29838. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  29839. /**
  29840. * Are diffuse textures enabled in the application.
  29841. */
  29842. static get DiffuseTextureEnabled(): boolean;
  29843. static set DiffuseTextureEnabled(value: boolean);
  29844. /**
  29845. * Are ambient textures enabled in the application.
  29846. */
  29847. static get AmbientTextureEnabled(): boolean;
  29848. static set AmbientTextureEnabled(value: boolean);
  29849. /**
  29850. * Are opacity textures enabled in the application.
  29851. */
  29852. static get OpacityTextureEnabled(): boolean;
  29853. static set OpacityTextureEnabled(value: boolean);
  29854. /**
  29855. * Are reflection textures enabled in the application.
  29856. */
  29857. static get ReflectionTextureEnabled(): boolean;
  29858. static set ReflectionTextureEnabled(value: boolean);
  29859. /**
  29860. * Are emissive textures enabled in the application.
  29861. */
  29862. static get EmissiveTextureEnabled(): boolean;
  29863. static set EmissiveTextureEnabled(value: boolean);
  29864. /**
  29865. * Are specular textures enabled in the application.
  29866. */
  29867. static get SpecularTextureEnabled(): boolean;
  29868. static set SpecularTextureEnabled(value: boolean);
  29869. /**
  29870. * Are bump textures enabled in the application.
  29871. */
  29872. static get BumpTextureEnabled(): boolean;
  29873. static set BumpTextureEnabled(value: boolean);
  29874. /**
  29875. * Are lightmap textures enabled in the application.
  29876. */
  29877. static get LightmapTextureEnabled(): boolean;
  29878. static set LightmapTextureEnabled(value: boolean);
  29879. /**
  29880. * Are refraction textures enabled in the application.
  29881. */
  29882. static get RefractionTextureEnabled(): boolean;
  29883. static set RefractionTextureEnabled(value: boolean);
  29884. /**
  29885. * Are color grading textures enabled in the application.
  29886. */
  29887. static get ColorGradingTextureEnabled(): boolean;
  29888. static set ColorGradingTextureEnabled(value: boolean);
  29889. /**
  29890. * Are fresnels enabled in the application.
  29891. */
  29892. static get FresnelEnabled(): boolean;
  29893. static set FresnelEnabled(value: boolean);
  29894. }
  29895. }
  29896. declare module BABYLON {
  29897. /**
  29898. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  29899. *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.
  29900. * The SPS is also a particle system. It provides some methods to manage the particles.
  29901. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  29902. *
  29903. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  29904. */
  29905. export class SolidParticleSystem implements IDisposable {
  29906. /**
  29907. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  29908. * Example : var p = SPS.particles[i];
  29909. */
  29910. particles: SolidParticle[];
  29911. /**
  29912. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  29913. */
  29914. nbParticles: number;
  29915. /**
  29916. * If the particles must ever face the camera (default false). Useful for planar particles.
  29917. */
  29918. billboard: boolean;
  29919. /**
  29920. * Recompute normals when adding a shape
  29921. */
  29922. recomputeNormals: boolean;
  29923. /**
  29924. * This a counter ofr your own usage. It's not set by any SPS functions.
  29925. */
  29926. counter: number;
  29927. /**
  29928. * The SPS name. This name is also given to the underlying mesh.
  29929. */
  29930. name: string;
  29931. /**
  29932. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  29933. */
  29934. mesh: Mesh;
  29935. /**
  29936. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  29937. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  29938. */
  29939. vars: any;
  29940. /**
  29941. * This array is populated when the SPS is set as 'pickable'.
  29942. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  29943. * Each element of this array is an object `{idx: int, faceId: int}`.
  29944. * `idx` is the picked particle index in the `SPS.particles` array
  29945. * `faceId` is the picked face index counted within this particle.
  29946. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  29947. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  29948. * Use the method SPS.pickedParticle(pickingInfo) instead.
  29949. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29950. */
  29951. pickedParticles: {
  29952. idx: number;
  29953. faceId: number;
  29954. }[];
  29955. /**
  29956. * This array is populated when the SPS is set as 'pickable'
  29957. * Each key of this array is a submesh index.
  29958. * Each element of this array is a second array defined like this :
  29959. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  29960. * Each element of this second array is an object `{idx: int, faceId: int}`.
  29961. * `idx` is the picked particle index in the `SPS.particles` array
  29962. * `faceId` is the picked face index counted within this particle.
  29963. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  29964. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  29965. */
  29966. pickedBySubMesh: {
  29967. idx: number;
  29968. faceId: number;
  29969. }[][];
  29970. /**
  29971. * This array is populated when `enableDepthSort` is set to true.
  29972. * Each element of this array is an instance of the class DepthSortedParticle.
  29973. */
  29974. depthSortedParticles: DepthSortedParticle[];
  29975. /**
  29976. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  29977. * @hidden
  29978. */
  29979. _bSphereOnly: boolean;
  29980. /**
  29981. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  29982. * @hidden
  29983. */
  29984. _bSphereRadiusFactor: number;
  29985. private _scene;
  29986. private _positions;
  29987. private _indices;
  29988. private _normals;
  29989. private _colors;
  29990. private _uvs;
  29991. private _indices32;
  29992. private _positions32;
  29993. private _normals32;
  29994. private _fixedNormal32;
  29995. private _colors32;
  29996. private _uvs32;
  29997. private _index;
  29998. private _updatable;
  29999. private _pickable;
  30000. private _isVisibilityBoxLocked;
  30001. private _alwaysVisible;
  30002. private _depthSort;
  30003. private _expandable;
  30004. private _shapeCounter;
  30005. private _copy;
  30006. private _color;
  30007. private _computeParticleColor;
  30008. private _computeParticleTexture;
  30009. private _computeParticleRotation;
  30010. private _computeParticleVertex;
  30011. private _computeBoundingBox;
  30012. private _depthSortParticles;
  30013. private _camera;
  30014. private _mustUnrotateFixedNormals;
  30015. private _particlesIntersect;
  30016. private _needs32Bits;
  30017. private _isNotBuilt;
  30018. private _lastParticleId;
  30019. private _idxOfId;
  30020. private _multimaterialEnabled;
  30021. private _useModelMaterial;
  30022. private _indicesByMaterial;
  30023. private _materialIndexes;
  30024. private _depthSortFunction;
  30025. private _materialSortFunction;
  30026. private _materials;
  30027. private _multimaterial;
  30028. private _materialIndexesById;
  30029. private _defaultMaterial;
  30030. private _autoUpdateSubMeshes;
  30031. private _tmpVertex;
  30032. /**
  30033. * Creates a SPS (Solid Particle System) object.
  30034. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30035. * @param scene (Scene) is the scene in which the SPS is added.
  30036. * @param options defines the options of the sps e.g.
  30037. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30038. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30039. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30040. * * 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.
  30041. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30042. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30043. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30044. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30045. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30046. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30047. */
  30048. constructor(name: string, scene: Scene, options?: {
  30049. updatable?: boolean;
  30050. isPickable?: boolean;
  30051. enableDepthSort?: boolean;
  30052. particleIntersection?: boolean;
  30053. boundingSphereOnly?: boolean;
  30054. bSphereRadiusFactor?: number;
  30055. expandable?: boolean;
  30056. useModelMaterial?: boolean;
  30057. enableMultiMaterial?: boolean;
  30058. });
  30059. /**
  30060. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30061. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30062. * @returns the created mesh
  30063. */
  30064. buildMesh(): Mesh;
  30065. /**
  30066. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30067. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30068. * Thus the particles generated from `digest()` have their property `position` set yet.
  30069. * @param mesh ( Mesh ) is the mesh to be digested
  30070. * @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
  30071. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30072. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30073. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30074. * @returns the current SPS
  30075. */
  30076. digest(mesh: Mesh, options?: {
  30077. facetNb?: number;
  30078. number?: number;
  30079. delta?: number;
  30080. storage?: [];
  30081. }): SolidParticleSystem;
  30082. /**
  30083. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30084. * @hidden
  30085. */
  30086. private _unrotateFixedNormals;
  30087. /**
  30088. * Resets the temporary working copy particle
  30089. * @hidden
  30090. */
  30091. private _resetCopy;
  30092. /**
  30093. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30094. * @param p the current index in the positions array to be updated
  30095. * @param ind the current index in the indices array
  30096. * @param shape a Vector3 array, the shape geometry
  30097. * @param positions the positions array to be updated
  30098. * @param meshInd the shape indices array
  30099. * @param indices the indices array to be updated
  30100. * @param meshUV the shape uv array
  30101. * @param uvs the uv array to be updated
  30102. * @param meshCol the shape color array
  30103. * @param colors the color array to be updated
  30104. * @param meshNor the shape normals array
  30105. * @param normals the normals array to be updated
  30106. * @param idx the particle index
  30107. * @param idxInShape the particle index in its shape
  30108. * @param options the addShape() method passed options
  30109. * @model the particle model
  30110. * @hidden
  30111. */
  30112. private _meshBuilder;
  30113. /**
  30114. * Returns a shape Vector3 array from positions float array
  30115. * @param positions float array
  30116. * @returns a vector3 array
  30117. * @hidden
  30118. */
  30119. private _posToShape;
  30120. /**
  30121. * Returns a shapeUV array from a float uvs (array deep copy)
  30122. * @param uvs as a float array
  30123. * @returns a shapeUV array
  30124. * @hidden
  30125. */
  30126. private _uvsToShapeUV;
  30127. /**
  30128. * Adds a new particle object in the particles array
  30129. * @param idx particle index in particles array
  30130. * @param id particle id
  30131. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30132. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30133. * @param model particle ModelShape object
  30134. * @param shapeId model shape identifier
  30135. * @param idxInShape index of the particle in the current model
  30136. * @param bInfo model bounding info object
  30137. * @param storage target storage array, if any
  30138. * @hidden
  30139. */
  30140. private _addParticle;
  30141. /**
  30142. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30143. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30144. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30145. * @param nb (positive integer) the number of particles to be created from this model
  30146. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30147. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30148. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30149. * @returns the number of shapes in the system
  30150. */
  30151. addShape(mesh: Mesh, nb: number, options?: {
  30152. positionFunction?: any;
  30153. vertexFunction?: any;
  30154. storage?: [];
  30155. }): number;
  30156. /**
  30157. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30158. * @hidden
  30159. */
  30160. private _rebuildParticle;
  30161. /**
  30162. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30163. * @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.
  30164. * @returns the SPS.
  30165. */
  30166. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30167. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30168. * Returns an array with the removed particles.
  30169. * 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.
  30170. * The SPS can't be empty so at least one particle needs to remain in place.
  30171. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30172. * @param start index of the first particle to remove
  30173. * @param end index of the last particle to remove (included)
  30174. * @returns an array populated with the removed particles
  30175. */
  30176. removeParticles(start: number, end: number): SolidParticle[];
  30177. /**
  30178. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30179. * @param solidParticleArray an array populated with Solid Particles objects
  30180. * @returns the SPS
  30181. */
  30182. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30183. /**
  30184. * Creates a new particle and modifies the SPS mesh geometry :
  30185. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30186. * - calls _addParticle() to populate the particle array
  30187. * factorized code from addShape() and insertParticlesFromArray()
  30188. * @param idx particle index in the particles array
  30189. * @param i particle index in its shape
  30190. * @param modelShape particle ModelShape object
  30191. * @param shape shape vertex array
  30192. * @param meshInd shape indices array
  30193. * @param meshUV shape uv array
  30194. * @param meshCol shape color array
  30195. * @param meshNor shape normals array
  30196. * @param bbInfo shape bounding info
  30197. * @param storage target particle storage
  30198. * @options addShape() passed options
  30199. * @hidden
  30200. */
  30201. private _insertNewParticle;
  30202. /**
  30203. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30204. * This method calls `updateParticle()` for each particle of the SPS.
  30205. * For an animated SPS, it is usually called within the render loop.
  30206. * 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.
  30207. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30208. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30209. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30210. * @returns the SPS.
  30211. */
  30212. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30213. /**
  30214. * Disposes the SPS.
  30215. */
  30216. dispose(): void;
  30217. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30218. * idx is the particle index in the SPS
  30219. * faceId is the picked face index counted within this particle.
  30220. * Returns null if the pickInfo can't identify a picked particle.
  30221. * @param pickingInfo (PickingInfo object)
  30222. * @returns {idx: number, faceId: number} or null
  30223. */
  30224. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30225. idx: number;
  30226. faceId: number;
  30227. }>;
  30228. /**
  30229. * Returns a SolidParticle object from its identifier : particle.id
  30230. * @param id (integer) the particle Id
  30231. * @returns the searched particle or null if not found in the SPS.
  30232. */
  30233. getParticleById(id: number): Nullable<SolidParticle>;
  30234. /**
  30235. * Returns a new array populated with the particles having the passed shapeId.
  30236. * @param shapeId (integer) the shape identifier
  30237. * @returns a new solid particle array
  30238. */
  30239. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30240. /**
  30241. * Populates the passed array "ref" with the particles having the passed shapeId.
  30242. * @param shapeId the shape identifier
  30243. * @returns the SPS
  30244. * @param ref
  30245. */
  30246. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30247. /**
  30248. * Computes the required SubMeshes according the materials assigned to the particles.
  30249. * @returns the solid particle system.
  30250. * Does nothing if called before the SPS mesh is built.
  30251. */
  30252. computeSubMeshes(): SolidParticleSystem;
  30253. /**
  30254. * Sorts the solid particles by material when MultiMaterial is enabled.
  30255. * Updates the indices32 array.
  30256. * Updates the indicesByMaterial array.
  30257. * Updates the mesh indices array.
  30258. * @returns the SPS
  30259. * @hidden
  30260. */
  30261. private _sortParticlesByMaterial;
  30262. /**
  30263. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30264. * @hidden
  30265. */
  30266. private _setMaterialIndexesById;
  30267. /**
  30268. * Returns an array with unique values of Materials from the passed array
  30269. * @param array the material array to be checked and filtered
  30270. * @hidden
  30271. */
  30272. private _filterUniqueMaterialId;
  30273. /**
  30274. * Sets a new Standard Material as _defaultMaterial if not already set.
  30275. * @hidden
  30276. */
  30277. private _setDefaultMaterial;
  30278. /**
  30279. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30280. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30281. * @returns the SPS.
  30282. */
  30283. refreshVisibleSize(): SolidParticleSystem;
  30284. /**
  30285. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30286. * @param size the size (float) of the visibility box
  30287. * note : this doesn't lock the SPS mesh bounding box.
  30288. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30289. */
  30290. setVisibilityBox(size: number): void;
  30291. /**
  30292. * Gets whether the SPS as always visible or not
  30293. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30294. */
  30295. get isAlwaysVisible(): boolean;
  30296. /**
  30297. * Sets the SPS as always visible or not
  30298. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30299. */
  30300. set isAlwaysVisible(val: boolean);
  30301. /**
  30302. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30303. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30304. */
  30305. set isVisibilityBoxLocked(val: boolean);
  30306. /**
  30307. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30308. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30309. */
  30310. get isVisibilityBoxLocked(): boolean;
  30311. /**
  30312. * Tells to `setParticles()` to compute the particle rotations or not.
  30313. * Default value : true. The SPS is faster when it's set to false.
  30314. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30315. */
  30316. set computeParticleRotation(val: boolean);
  30317. /**
  30318. * Tells to `setParticles()` to compute the particle colors or not.
  30319. * Default value : true. The SPS is faster when it's set to false.
  30320. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30321. */
  30322. set computeParticleColor(val: boolean);
  30323. set computeParticleTexture(val: boolean);
  30324. /**
  30325. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30326. * Default value : false. The SPS is faster when it's set to false.
  30327. * Note : the particle custom vertex positions aren't stored values.
  30328. */
  30329. set computeParticleVertex(val: boolean);
  30330. /**
  30331. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30332. */
  30333. set computeBoundingBox(val: boolean);
  30334. /**
  30335. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30336. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30337. * Default : `true`
  30338. */
  30339. set depthSortParticles(val: boolean);
  30340. /**
  30341. * Gets if `setParticles()` computes the particle rotations or not.
  30342. * Default value : true. The SPS is faster when it's set to false.
  30343. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30344. */
  30345. get computeParticleRotation(): boolean;
  30346. /**
  30347. * Gets if `setParticles()` computes the particle colors or not.
  30348. * Default value : true. The SPS is faster when it's set to false.
  30349. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30350. */
  30351. get computeParticleColor(): boolean;
  30352. /**
  30353. * Gets if `setParticles()` computes the particle textures or not.
  30354. * Default value : true. The SPS is faster when it's set to false.
  30355. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30356. */
  30357. get computeParticleTexture(): boolean;
  30358. /**
  30359. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30360. * Default value : false. The SPS is faster when it's set to false.
  30361. * Note : the particle custom vertex positions aren't stored values.
  30362. */
  30363. get computeParticleVertex(): boolean;
  30364. /**
  30365. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30366. */
  30367. get computeBoundingBox(): boolean;
  30368. /**
  30369. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30370. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30371. * Default : `true`
  30372. */
  30373. get depthSortParticles(): boolean;
  30374. /**
  30375. * Gets if the SPS is created as expandable at construction time.
  30376. * Default : `false`
  30377. */
  30378. get expandable(): boolean;
  30379. /**
  30380. * Gets if the SPS supports the Multi Materials
  30381. */
  30382. get multimaterialEnabled(): boolean;
  30383. /**
  30384. * Gets if the SPS uses the model materials for its own multimaterial.
  30385. */
  30386. get useModelMaterial(): boolean;
  30387. /**
  30388. * The SPS used material array.
  30389. */
  30390. get materials(): Material[];
  30391. /**
  30392. * Sets the SPS MultiMaterial from the passed materials.
  30393. * Note : the passed array is internally copied and not used then by reference.
  30394. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30395. */
  30396. setMultiMaterial(materials: Material[]): void;
  30397. /**
  30398. * The SPS computed multimaterial object
  30399. */
  30400. get multimaterial(): MultiMaterial;
  30401. set multimaterial(mm: MultiMaterial);
  30402. /**
  30403. * If the subMeshes must be updated on the next call to setParticles()
  30404. */
  30405. get autoUpdateSubMeshes(): boolean;
  30406. set autoUpdateSubMeshes(val: boolean);
  30407. /**
  30408. * This function does nothing. It may be overwritten to set all the particle first values.
  30409. * The SPS doesn't call this function, you may have to call it by your own.
  30410. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30411. */
  30412. initParticles(): void;
  30413. /**
  30414. * This function does nothing. It may be overwritten to recycle a particle.
  30415. * The SPS doesn't call this function, you may have to call it by your own.
  30416. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30417. * @param particle The particle to recycle
  30418. * @returns the recycled particle
  30419. */
  30420. recycleParticle(particle: SolidParticle): SolidParticle;
  30421. /**
  30422. * Updates a particle : this function should be overwritten by the user.
  30423. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30424. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30425. * @example : just set a particle position or velocity and recycle conditions
  30426. * @param particle The particle to update
  30427. * @returns the updated particle
  30428. */
  30429. updateParticle(particle: SolidParticle): SolidParticle;
  30430. /**
  30431. * Updates a vertex of a particle : it can be overwritten by the user.
  30432. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30433. * @param particle the current particle
  30434. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30435. * @param pt the index of the current vertex in the particle shape
  30436. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30437. * @example : just set a vertex particle position or color
  30438. * @returns the sps
  30439. */
  30440. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30441. /**
  30442. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30443. * This does nothing and may be overwritten by the user.
  30444. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30445. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30446. * @param update the boolean update value actually passed to setParticles()
  30447. */
  30448. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30449. /**
  30450. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30451. * This will be passed three parameters.
  30452. * This does nothing and may be overwritten by the user.
  30453. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30454. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30455. * @param update the boolean update value actually passed to setParticles()
  30456. */
  30457. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30458. }
  30459. }
  30460. declare module BABYLON {
  30461. /**
  30462. * Represents one particle of a solid particle system.
  30463. */
  30464. export class SolidParticle {
  30465. /**
  30466. * particle global index
  30467. */
  30468. idx: number;
  30469. /**
  30470. * particle identifier
  30471. */
  30472. id: number;
  30473. /**
  30474. * The color of the particle
  30475. */
  30476. color: Nullable<Color4>;
  30477. /**
  30478. * The world space position of the particle.
  30479. */
  30480. position: Vector3;
  30481. /**
  30482. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30483. */
  30484. rotation: Vector3;
  30485. /**
  30486. * The world space rotation quaternion of the particle.
  30487. */
  30488. rotationQuaternion: Nullable<Quaternion>;
  30489. /**
  30490. * The scaling of the particle.
  30491. */
  30492. scaling: Vector3;
  30493. /**
  30494. * The uvs of the particle.
  30495. */
  30496. uvs: Vector4;
  30497. /**
  30498. * The current speed of the particle.
  30499. */
  30500. velocity: Vector3;
  30501. /**
  30502. * The pivot point in the particle local space.
  30503. */
  30504. pivot: Vector3;
  30505. /**
  30506. * Must the particle be translated from its pivot point in its local space ?
  30507. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30508. * Default : false
  30509. */
  30510. translateFromPivot: boolean;
  30511. /**
  30512. * Is the particle active or not ?
  30513. */
  30514. alive: boolean;
  30515. /**
  30516. * Is the particle visible or not ?
  30517. */
  30518. isVisible: boolean;
  30519. /**
  30520. * Index of this particle in the global "positions" array (Internal use)
  30521. * @hidden
  30522. */
  30523. _pos: number;
  30524. /**
  30525. * @hidden Index of this particle in the global "indices" array (Internal use)
  30526. */
  30527. _ind: number;
  30528. /**
  30529. * @hidden ModelShape of this particle (Internal use)
  30530. */
  30531. _model: ModelShape;
  30532. /**
  30533. * ModelShape id of this particle
  30534. */
  30535. shapeId: number;
  30536. /**
  30537. * Index of the particle in its shape id
  30538. */
  30539. idxInShape: number;
  30540. /**
  30541. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30542. */
  30543. _modelBoundingInfo: BoundingInfo;
  30544. /**
  30545. * @hidden Particle BoundingInfo object (Internal use)
  30546. */
  30547. _boundingInfo: BoundingInfo;
  30548. /**
  30549. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30550. */
  30551. _sps: SolidParticleSystem;
  30552. /**
  30553. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30554. */
  30555. _stillInvisible: boolean;
  30556. /**
  30557. * @hidden Last computed particle rotation matrix
  30558. */
  30559. _rotationMatrix: number[];
  30560. /**
  30561. * Parent particle Id, if any.
  30562. * Default null.
  30563. */
  30564. parentId: Nullable<number>;
  30565. /**
  30566. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30567. */
  30568. materialIndex: Nullable<number>;
  30569. /**
  30570. * Custom object or properties.
  30571. */
  30572. props: Nullable<any>;
  30573. /**
  30574. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30575. * The possible values are :
  30576. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30577. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30578. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30579. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30580. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30581. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30582. * */
  30583. cullingStrategy: number;
  30584. /**
  30585. * @hidden Internal global position in the SPS.
  30586. */
  30587. _globalPosition: Vector3;
  30588. /**
  30589. * Creates a Solid Particle object.
  30590. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30591. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30592. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30593. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30594. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30595. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30596. * @param shapeId (integer) is the model shape identifier in the SPS.
  30597. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30598. * @param sps defines the sps it is associated to
  30599. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30600. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30601. */
  30602. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30603. /**
  30604. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30605. * @param target the particle target
  30606. * @returns the current particle
  30607. */
  30608. copyToRef(target: SolidParticle): SolidParticle;
  30609. /**
  30610. * Legacy support, changed scale to scaling
  30611. */
  30612. get scale(): Vector3;
  30613. /**
  30614. * Legacy support, changed scale to scaling
  30615. */
  30616. set scale(scale: Vector3);
  30617. /**
  30618. * Legacy support, changed quaternion to rotationQuaternion
  30619. */
  30620. get quaternion(): Nullable<Quaternion>;
  30621. /**
  30622. * Legacy support, changed quaternion to rotationQuaternion
  30623. */
  30624. set quaternion(q: Nullable<Quaternion>);
  30625. /**
  30626. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30627. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30628. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30629. * @returns true if it intersects
  30630. */
  30631. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30632. /**
  30633. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30634. * A particle is in the frustum if its bounding box intersects the frustum
  30635. * @param frustumPlanes defines the frustum to test
  30636. * @returns true if the particle is in the frustum planes
  30637. */
  30638. isInFrustum(frustumPlanes: Plane[]): boolean;
  30639. /**
  30640. * get the rotation matrix of the particle
  30641. * @hidden
  30642. */
  30643. getRotationMatrix(m: Matrix): void;
  30644. }
  30645. /**
  30646. * Represents the shape of the model used by one particle of a solid particle system.
  30647. * SPS internal tool, don't use it manually.
  30648. */
  30649. export class ModelShape {
  30650. /**
  30651. * The shape id
  30652. * @hidden
  30653. */
  30654. shapeID: number;
  30655. /**
  30656. * flat array of model positions (internal use)
  30657. * @hidden
  30658. */
  30659. _shape: Vector3[];
  30660. /**
  30661. * flat array of model UVs (internal use)
  30662. * @hidden
  30663. */
  30664. _shapeUV: number[];
  30665. /**
  30666. * color array of the model
  30667. * @hidden
  30668. */
  30669. _shapeColors: number[];
  30670. /**
  30671. * indices array of the model
  30672. * @hidden
  30673. */
  30674. _indices: number[];
  30675. /**
  30676. * normals array of the model
  30677. * @hidden
  30678. */
  30679. _normals: number[];
  30680. /**
  30681. * length of the shape in the model indices array (internal use)
  30682. * @hidden
  30683. */
  30684. _indicesLength: number;
  30685. /**
  30686. * Custom position function (internal use)
  30687. * @hidden
  30688. */
  30689. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30690. /**
  30691. * Custom vertex function (internal use)
  30692. * @hidden
  30693. */
  30694. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30695. /**
  30696. * Model material (internal use)
  30697. * @hidden
  30698. */
  30699. _material: Nullable<Material>;
  30700. /**
  30701. * 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.
  30702. * SPS internal tool, don't use it manually.
  30703. * @hidden
  30704. */
  30705. 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>);
  30706. }
  30707. /**
  30708. * Represents a Depth Sorted Particle in the solid particle system.
  30709. * @hidden
  30710. */
  30711. export class DepthSortedParticle {
  30712. /**
  30713. * Particle index
  30714. */
  30715. idx: number;
  30716. /**
  30717. * Index of the particle in the "indices" array
  30718. */
  30719. ind: number;
  30720. /**
  30721. * Length of the particle shape in the "indices" array
  30722. */
  30723. indicesLength: number;
  30724. /**
  30725. * Squared distance from the particle to the camera
  30726. */
  30727. sqDistance: number;
  30728. /**
  30729. * Material index when used with MultiMaterials
  30730. */
  30731. materialIndex: number;
  30732. /**
  30733. * Creates a new sorted particle
  30734. * @param materialIndex
  30735. */
  30736. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30737. }
  30738. /**
  30739. * Represents a solid particle vertex
  30740. */
  30741. export class SolidParticleVertex {
  30742. /**
  30743. * Vertex position
  30744. */
  30745. position: Vector3;
  30746. /**
  30747. * Vertex color
  30748. */
  30749. color: Color4;
  30750. /**
  30751. * Vertex UV
  30752. */
  30753. uv: Vector2;
  30754. /**
  30755. * Creates a new solid particle vertex
  30756. */
  30757. constructor();
  30758. /** Vertex x coordinate */
  30759. get x(): number;
  30760. set x(val: number);
  30761. /** Vertex y coordinate */
  30762. get y(): number;
  30763. set y(val: number);
  30764. /** Vertex z coordinate */
  30765. get z(): number;
  30766. set z(val: number);
  30767. }
  30768. }
  30769. declare module BABYLON {
  30770. /**
  30771. * @hidden
  30772. */
  30773. export class _MeshCollisionData {
  30774. _checkCollisions: boolean;
  30775. _collisionMask: number;
  30776. _collisionGroup: number;
  30777. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30778. _collider: Nullable<Collider>;
  30779. _oldPositionForCollisions: Vector3;
  30780. _diffPositionForCollisions: Vector3;
  30781. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30782. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30783. }
  30784. }
  30785. declare module BABYLON {
  30786. /** @hidden */
  30787. class _FacetDataStorage {
  30788. facetPositions: Vector3[];
  30789. facetNormals: Vector3[];
  30790. facetPartitioning: number[][];
  30791. facetNb: number;
  30792. partitioningSubdivisions: number;
  30793. partitioningBBoxRatio: number;
  30794. facetDataEnabled: boolean;
  30795. facetParameters: any;
  30796. bbSize: Vector3;
  30797. subDiv: {
  30798. max: number;
  30799. X: number;
  30800. Y: number;
  30801. Z: number;
  30802. };
  30803. facetDepthSort: boolean;
  30804. facetDepthSortEnabled: boolean;
  30805. depthSortedIndices: IndicesArray;
  30806. depthSortedFacets: {
  30807. ind: number;
  30808. sqDistance: number;
  30809. }[];
  30810. facetDepthSortFunction: (f1: {
  30811. ind: number;
  30812. sqDistance: number;
  30813. }, f2: {
  30814. ind: number;
  30815. sqDistance: number;
  30816. }) => number;
  30817. facetDepthSortFrom: Vector3;
  30818. facetDepthSortOrigin: Vector3;
  30819. invertedMatrix: Matrix;
  30820. }
  30821. /**
  30822. * @hidden
  30823. **/
  30824. class _InternalAbstractMeshDataInfo {
  30825. _hasVertexAlpha: boolean;
  30826. _useVertexColors: boolean;
  30827. _numBoneInfluencers: number;
  30828. _applyFog: boolean;
  30829. _receiveShadows: boolean;
  30830. _facetData: _FacetDataStorage;
  30831. _visibility: number;
  30832. _skeleton: Nullable<Skeleton>;
  30833. _layerMask: number;
  30834. _computeBonesUsingShaders: boolean;
  30835. _isActive: boolean;
  30836. _onlyForInstances: boolean;
  30837. _isActiveIntermediate: boolean;
  30838. _onlyForInstancesIntermediate: boolean;
  30839. _actAsRegularMesh: boolean;
  30840. }
  30841. /**
  30842. * Class used to store all common mesh properties
  30843. */
  30844. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  30845. /** No occlusion */
  30846. static OCCLUSION_TYPE_NONE: number;
  30847. /** Occlusion set to optimisitic */
  30848. static OCCLUSION_TYPE_OPTIMISTIC: number;
  30849. /** Occlusion set to strict */
  30850. static OCCLUSION_TYPE_STRICT: number;
  30851. /** Use an accurante occlusion algorithm */
  30852. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  30853. /** Use a conservative occlusion algorithm */
  30854. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  30855. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  30856. * Test order :
  30857. * Is the bounding sphere outside the frustum ?
  30858. * If not, are the bounding box vertices outside the frustum ?
  30859. * It not, then the cullable object is in the frustum.
  30860. */
  30861. static readonly CULLINGSTRATEGY_STANDARD: number;
  30862. /** Culling strategy : Bounding Sphere Only.
  30863. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  30864. * It's also less accurate than the standard because some not visible objects can still be selected.
  30865. * Test : is the bounding sphere outside the frustum ?
  30866. * If not, then the cullable object is in the frustum.
  30867. */
  30868. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  30869. /** Culling strategy : Optimistic Inclusion.
  30870. * This in an inclusion test first, then the standard exclusion test.
  30871. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  30872. * 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.
  30873. * Anyway, it's as accurate as the standard strategy.
  30874. * Test :
  30875. * Is the cullable object bounding sphere center in the frustum ?
  30876. * If not, apply the default culling strategy.
  30877. */
  30878. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  30879. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  30880. * This in an inclusion test first, then the bounding sphere only exclusion test.
  30881. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  30882. * 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.
  30883. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  30884. * Test :
  30885. * Is the cullable object bounding sphere center in the frustum ?
  30886. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  30887. */
  30888. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  30889. /**
  30890. * No billboard
  30891. */
  30892. static get BILLBOARDMODE_NONE(): number;
  30893. /** Billboard on X axis */
  30894. static get BILLBOARDMODE_X(): number;
  30895. /** Billboard on Y axis */
  30896. static get BILLBOARDMODE_Y(): number;
  30897. /** Billboard on Z axis */
  30898. static get BILLBOARDMODE_Z(): number;
  30899. /** Billboard on all axes */
  30900. static get BILLBOARDMODE_ALL(): number;
  30901. /** Billboard on using position instead of orientation */
  30902. static get BILLBOARDMODE_USE_POSITION(): number;
  30903. /** @hidden */
  30904. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  30905. /**
  30906. * The culling strategy to use to check whether the mesh must be rendered or not.
  30907. * This value can be changed at any time and will be used on the next render mesh selection.
  30908. * The possible values are :
  30909. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30910. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30911. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30912. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30913. * Please read each static variable documentation to get details about the culling process.
  30914. * */
  30915. cullingStrategy: number;
  30916. /**
  30917. * Gets the number of facets in the mesh
  30918. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30919. */
  30920. get facetNb(): number;
  30921. /**
  30922. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  30923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30924. */
  30925. get partitioningSubdivisions(): number;
  30926. set partitioningSubdivisions(nb: number);
  30927. /**
  30928. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  30929. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  30930. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  30931. */
  30932. get partitioningBBoxRatio(): number;
  30933. set partitioningBBoxRatio(ratio: number);
  30934. /**
  30935. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  30936. * Works only for updatable meshes.
  30937. * Doesn't work with multi-materials
  30938. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30939. */
  30940. get mustDepthSortFacets(): boolean;
  30941. set mustDepthSortFacets(sort: boolean);
  30942. /**
  30943. * The location (Vector3) where the facet depth sort must be computed from.
  30944. * By default, the active camera position.
  30945. * Used only when facet depth sort is enabled
  30946. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  30947. */
  30948. get facetDepthSortFrom(): Vector3;
  30949. set facetDepthSortFrom(location: Vector3);
  30950. /**
  30951. * gets a boolean indicating if facetData is enabled
  30952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  30953. */
  30954. get isFacetDataEnabled(): boolean;
  30955. /** @hidden */
  30956. _updateNonUniformScalingState(value: boolean): boolean;
  30957. /**
  30958. * An event triggered when this mesh collides with another one
  30959. */
  30960. onCollideObservable: Observable<AbstractMesh>;
  30961. /** Set a function to call when this mesh collides with another one */
  30962. set onCollide(callback: () => void);
  30963. /**
  30964. * An event triggered when the collision's position changes
  30965. */
  30966. onCollisionPositionChangeObservable: Observable<Vector3>;
  30967. /** Set a function to call when the collision's position changes */
  30968. set onCollisionPositionChange(callback: () => void);
  30969. /**
  30970. * An event triggered when material is changed
  30971. */
  30972. onMaterialChangedObservable: Observable<AbstractMesh>;
  30973. /**
  30974. * Gets or sets the orientation for POV movement & rotation
  30975. */
  30976. definedFacingForward: boolean;
  30977. /** @hidden */
  30978. _occlusionQuery: Nullable<WebGLQuery>;
  30979. /** @hidden */
  30980. _renderingGroup: Nullable<RenderingGroup>;
  30981. /**
  30982. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30983. */
  30984. get visibility(): number;
  30985. /**
  30986. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  30987. */
  30988. set visibility(value: number);
  30989. /** Gets or sets the alpha index used to sort transparent meshes
  30990. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  30991. */
  30992. alphaIndex: number;
  30993. /**
  30994. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  30995. */
  30996. isVisible: boolean;
  30997. /**
  30998. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  30999. */
  31000. isPickable: boolean;
  31001. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31002. showSubMeshesBoundingBox: boolean;
  31003. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31004. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31005. */
  31006. isBlocker: boolean;
  31007. /**
  31008. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31009. */
  31010. enablePointerMoveEvents: boolean;
  31011. /**
  31012. * Specifies the rendering group id for this mesh (0 by default)
  31013. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31014. */
  31015. renderingGroupId: number;
  31016. private _material;
  31017. /** Gets or sets current material */
  31018. get material(): Nullable<Material>;
  31019. set material(value: Nullable<Material>);
  31020. /**
  31021. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31022. * @see http://doc.babylonjs.com/babylon101/shadows
  31023. */
  31024. get receiveShadows(): boolean;
  31025. set receiveShadows(value: boolean);
  31026. /** Defines color to use when rendering outline */
  31027. outlineColor: Color3;
  31028. /** Define width to use when rendering outline */
  31029. outlineWidth: number;
  31030. /** Defines color to use when rendering overlay */
  31031. overlayColor: Color3;
  31032. /** Defines alpha to use when rendering overlay */
  31033. overlayAlpha: number;
  31034. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31035. get hasVertexAlpha(): boolean;
  31036. set hasVertexAlpha(value: boolean);
  31037. /** 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) */
  31038. get useVertexColors(): boolean;
  31039. set useVertexColors(value: boolean);
  31040. /**
  31041. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31042. */
  31043. get computeBonesUsingShaders(): boolean;
  31044. set computeBonesUsingShaders(value: boolean);
  31045. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31046. get numBoneInfluencers(): number;
  31047. set numBoneInfluencers(value: number);
  31048. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31049. get applyFog(): boolean;
  31050. set applyFog(value: boolean);
  31051. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31052. useOctreeForRenderingSelection: boolean;
  31053. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31054. useOctreeForPicking: boolean;
  31055. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31056. useOctreeForCollisions: boolean;
  31057. /**
  31058. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31059. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31060. */
  31061. get layerMask(): number;
  31062. set layerMask(value: number);
  31063. /**
  31064. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31065. */
  31066. alwaysSelectAsActiveMesh: boolean;
  31067. /**
  31068. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31069. */
  31070. doNotSyncBoundingInfo: boolean;
  31071. /**
  31072. * Gets or sets the current action manager
  31073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31074. */
  31075. actionManager: Nullable<AbstractActionManager>;
  31076. private _meshCollisionData;
  31077. /**
  31078. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31079. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31080. */
  31081. ellipsoid: Vector3;
  31082. /**
  31083. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31084. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31085. */
  31086. ellipsoidOffset: Vector3;
  31087. /**
  31088. * Gets or sets a collision mask used to mask collisions (default is -1).
  31089. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31090. */
  31091. get collisionMask(): number;
  31092. set collisionMask(mask: number);
  31093. /**
  31094. * Gets or sets the current collision group mask (-1 by default).
  31095. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31096. */
  31097. get collisionGroup(): number;
  31098. set collisionGroup(mask: number);
  31099. /**
  31100. * Gets or sets current surrounding meshes (null by default).
  31101. *
  31102. * By default collision detection is tested against every mesh in the scene.
  31103. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31104. * meshes will be tested for the collision.
  31105. *
  31106. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31107. */
  31108. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31109. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31110. /**
  31111. * Defines edge width used when edgesRenderer is enabled
  31112. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31113. */
  31114. edgesWidth: number;
  31115. /**
  31116. * Defines edge color used when edgesRenderer is enabled
  31117. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31118. */
  31119. edgesColor: Color4;
  31120. /** @hidden */
  31121. _edgesRenderer: Nullable<IEdgesRenderer>;
  31122. /** @hidden */
  31123. _masterMesh: Nullable<AbstractMesh>;
  31124. /** @hidden */
  31125. _boundingInfo: Nullable<BoundingInfo>;
  31126. /** @hidden */
  31127. _renderId: number;
  31128. /**
  31129. * Gets or sets the list of subMeshes
  31130. * @see http://doc.babylonjs.com/how_to/multi_materials
  31131. */
  31132. subMeshes: SubMesh[];
  31133. /** @hidden */
  31134. _intersectionsInProgress: AbstractMesh[];
  31135. /** @hidden */
  31136. _unIndexed: boolean;
  31137. /** @hidden */
  31138. _lightSources: Light[];
  31139. /** Gets the list of lights affecting that mesh */
  31140. get lightSources(): Light[];
  31141. /** @hidden */
  31142. get _positions(): Nullable<Vector3[]>;
  31143. /** @hidden */
  31144. _waitingData: {
  31145. lods: Nullable<any>;
  31146. actions: Nullable<any>;
  31147. freezeWorldMatrix: Nullable<boolean>;
  31148. };
  31149. /** @hidden */
  31150. _bonesTransformMatrices: Nullable<Float32Array>;
  31151. /** @hidden */
  31152. _transformMatrixTexture: Nullable<RawTexture>;
  31153. /**
  31154. * Gets or sets a skeleton to apply skining transformations
  31155. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31156. */
  31157. set skeleton(value: Nullable<Skeleton>);
  31158. get skeleton(): Nullable<Skeleton>;
  31159. /**
  31160. * An event triggered when the mesh is rebuilt.
  31161. */
  31162. onRebuildObservable: Observable<AbstractMesh>;
  31163. /**
  31164. * Creates a new AbstractMesh
  31165. * @param name defines the name of the mesh
  31166. * @param scene defines the hosting scene
  31167. */
  31168. constructor(name: string, scene?: Nullable<Scene>);
  31169. /**
  31170. * Returns the string "AbstractMesh"
  31171. * @returns "AbstractMesh"
  31172. */
  31173. getClassName(): string;
  31174. /**
  31175. * Gets a string representation of the current mesh
  31176. * @param fullDetails defines a boolean indicating if full details must be included
  31177. * @returns a string representation of the current mesh
  31178. */
  31179. toString(fullDetails?: boolean): string;
  31180. /**
  31181. * @hidden
  31182. */
  31183. protected _getEffectiveParent(): Nullable<Node>;
  31184. /** @hidden */
  31185. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31186. /** @hidden */
  31187. _rebuild(): void;
  31188. /** @hidden */
  31189. _resyncLightSources(): void;
  31190. /** @hidden */
  31191. _resyncLightSource(light: Light): void;
  31192. /** @hidden */
  31193. _unBindEffect(): void;
  31194. /** @hidden */
  31195. _removeLightSource(light: Light, dispose: boolean): void;
  31196. private _markSubMeshesAsDirty;
  31197. /** @hidden */
  31198. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31199. /** @hidden */
  31200. _markSubMeshesAsAttributesDirty(): void;
  31201. /** @hidden */
  31202. _markSubMeshesAsMiscDirty(): void;
  31203. /**
  31204. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31205. */
  31206. get scaling(): Vector3;
  31207. set scaling(newScaling: Vector3);
  31208. /**
  31209. * Returns true if the mesh is blocked. Implemented by child classes
  31210. */
  31211. get isBlocked(): boolean;
  31212. /**
  31213. * Returns the mesh itself by default. Implemented by child classes
  31214. * @param camera defines the camera to use to pick the right LOD level
  31215. * @returns the currentAbstractMesh
  31216. */
  31217. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31218. /**
  31219. * Returns 0 by default. Implemented by child classes
  31220. * @returns an integer
  31221. */
  31222. getTotalVertices(): number;
  31223. /**
  31224. * Returns a positive integer : the total number of indices in this mesh geometry.
  31225. * @returns the numner of indices or zero if the mesh has no geometry.
  31226. */
  31227. getTotalIndices(): number;
  31228. /**
  31229. * Returns null by default. Implemented by child classes
  31230. * @returns null
  31231. */
  31232. getIndices(): Nullable<IndicesArray>;
  31233. /**
  31234. * Returns the array of the requested vertex data kind. Implemented by child classes
  31235. * @param kind defines the vertex data kind to use
  31236. * @returns null
  31237. */
  31238. getVerticesData(kind: string): Nullable<FloatArray>;
  31239. /**
  31240. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31241. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31242. * Note that a new underlying VertexBuffer object is created each call.
  31243. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31244. * @param kind defines vertex data kind:
  31245. * * VertexBuffer.PositionKind
  31246. * * VertexBuffer.UVKind
  31247. * * VertexBuffer.UV2Kind
  31248. * * VertexBuffer.UV3Kind
  31249. * * VertexBuffer.UV4Kind
  31250. * * VertexBuffer.UV5Kind
  31251. * * VertexBuffer.UV6Kind
  31252. * * VertexBuffer.ColorKind
  31253. * * VertexBuffer.MatricesIndicesKind
  31254. * * VertexBuffer.MatricesIndicesExtraKind
  31255. * * VertexBuffer.MatricesWeightsKind
  31256. * * VertexBuffer.MatricesWeightsExtraKind
  31257. * @param data defines the data source
  31258. * @param updatable defines if the data must be flagged as updatable (or static)
  31259. * @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
  31260. * @returns the current mesh
  31261. */
  31262. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31263. /**
  31264. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31265. * If the mesh has no geometry, it is simply returned as it is.
  31266. * @param kind defines vertex data kind:
  31267. * * VertexBuffer.PositionKind
  31268. * * VertexBuffer.UVKind
  31269. * * VertexBuffer.UV2Kind
  31270. * * VertexBuffer.UV3Kind
  31271. * * VertexBuffer.UV4Kind
  31272. * * VertexBuffer.UV5Kind
  31273. * * VertexBuffer.UV6Kind
  31274. * * VertexBuffer.ColorKind
  31275. * * VertexBuffer.MatricesIndicesKind
  31276. * * VertexBuffer.MatricesIndicesExtraKind
  31277. * * VertexBuffer.MatricesWeightsKind
  31278. * * VertexBuffer.MatricesWeightsExtraKind
  31279. * @param data defines the data source
  31280. * @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
  31281. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31282. * @returns the current mesh
  31283. */
  31284. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31285. /**
  31286. * Sets the mesh indices,
  31287. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31288. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31289. * @param totalVertices Defines the total number of vertices
  31290. * @returns the current mesh
  31291. */
  31292. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31293. /**
  31294. * Gets a boolean indicating if specific vertex data is present
  31295. * @param kind defines the vertex data kind to use
  31296. * @returns true is data kind is present
  31297. */
  31298. isVerticesDataPresent(kind: string): boolean;
  31299. /**
  31300. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31301. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31302. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31303. * @returns a BoundingInfo
  31304. */
  31305. getBoundingInfo(): BoundingInfo;
  31306. /**
  31307. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31308. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31309. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31310. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31311. * @returns the current mesh
  31312. */
  31313. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31314. /**
  31315. * Overwrite the current bounding info
  31316. * @param boundingInfo defines the new bounding info
  31317. * @returns the current mesh
  31318. */
  31319. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31320. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31321. get useBones(): boolean;
  31322. /** @hidden */
  31323. _preActivate(): void;
  31324. /** @hidden */
  31325. _preActivateForIntermediateRendering(renderId: number): void;
  31326. /** @hidden */
  31327. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31328. /** @hidden */
  31329. _postActivate(): void;
  31330. /** @hidden */
  31331. _freeze(): void;
  31332. /** @hidden */
  31333. _unFreeze(): void;
  31334. /**
  31335. * Gets the current world matrix
  31336. * @returns a Matrix
  31337. */
  31338. getWorldMatrix(): Matrix;
  31339. /** @hidden */
  31340. _getWorldMatrixDeterminant(): number;
  31341. /**
  31342. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31343. */
  31344. get isAnInstance(): boolean;
  31345. /**
  31346. * Gets a boolean indicating if this mesh has instances
  31347. */
  31348. get hasInstances(): boolean;
  31349. /**
  31350. * Gets a boolean indicating if this mesh has thin instances
  31351. */
  31352. get hasThinInstances(): boolean;
  31353. /**
  31354. * Perform relative position change from the point of view of behind the front of the mesh.
  31355. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31356. * Supports definition of mesh facing forward or backward
  31357. * @param amountRight defines the distance on the right axis
  31358. * @param amountUp defines the distance on the up axis
  31359. * @param amountForward defines the distance on the forward axis
  31360. * @returns the current mesh
  31361. */
  31362. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31363. /**
  31364. * Calculate relative position change from the point of view of behind the front of the mesh.
  31365. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31366. * Supports definition of mesh facing forward or backward
  31367. * @param amountRight defines the distance on the right axis
  31368. * @param amountUp defines the distance on the up axis
  31369. * @param amountForward defines the distance on the forward axis
  31370. * @returns the new displacement vector
  31371. */
  31372. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31373. /**
  31374. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31375. * Supports definition of mesh facing forward or backward
  31376. * @param flipBack defines the flip
  31377. * @param twirlClockwise defines the twirl
  31378. * @param tiltRight defines the tilt
  31379. * @returns the current mesh
  31380. */
  31381. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31382. /**
  31383. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31384. * Supports definition of mesh facing forward or backward.
  31385. * @param flipBack defines the flip
  31386. * @param twirlClockwise defines the twirl
  31387. * @param tiltRight defines the tilt
  31388. * @returns the new rotation vector
  31389. */
  31390. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31391. /**
  31392. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31393. * This means the mesh underlying bounding box and sphere are recomputed.
  31394. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31395. * @returns the current mesh
  31396. */
  31397. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31398. /** @hidden */
  31399. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31400. /** @hidden */
  31401. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31402. /** @hidden */
  31403. _updateBoundingInfo(): AbstractMesh;
  31404. /** @hidden */
  31405. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31406. /** @hidden */
  31407. protected _afterComputeWorldMatrix(): void;
  31408. /** @hidden */
  31409. get _effectiveMesh(): AbstractMesh;
  31410. /**
  31411. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31412. * A mesh is in the frustum if its bounding box intersects the frustum
  31413. * @param frustumPlanes defines the frustum to test
  31414. * @returns true if the mesh is in the frustum planes
  31415. */
  31416. isInFrustum(frustumPlanes: Plane[]): boolean;
  31417. /**
  31418. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31419. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31420. * @param frustumPlanes defines the frustum to test
  31421. * @returns true if the mesh is completely in the frustum planes
  31422. */
  31423. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31424. /**
  31425. * True if the mesh intersects another mesh or a SolidParticle object
  31426. * @param mesh defines a target mesh or SolidParticle to test
  31427. * @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)
  31428. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31429. * @returns true if there is an intersection
  31430. */
  31431. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31432. /**
  31433. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31434. * @param point defines the point to test
  31435. * @returns true if there is an intersection
  31436. */
  31437. intersectsPoint(point: Vector3): boolean;
  31438. /**
  31439. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31440. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31441. */
  31442. get checkCollisions(): boolean;
  31443. set checkCollisions(collisionEnabled: boolean);
  31444. /**
  31445. * Gets Collider object used to compute collisions (not physics)
  31446. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31447. */
  31448. get collider(): Nullable<Collider>;
  31449. /**
  31450. * Move the mesh using collision engine
  31451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31452. * @param displacement defines the requested displacement vector
  31453. * @returns the current mesh
  31454. */
  31455. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31456. private _onCollisionPositionChange;
  31457. /** @hidden */
  31458. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31459. /** @hidden */
  31460. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31461. /** @hidden */
  31462. _checkCollision(collider: Collider): AbstractMesh;
  31463. /** @hidden */
  31464. _generatePointsArray(): boolean;
  31465. /**
  31466. * Checks if the passed Ray intersects with the mesh
  31467. * @param ray defines the ray to use
  31468. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31469. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31470. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31471. * @returns the picking info
  31472. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31473. */
  31474. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31475. /**
  31476. * Clones the current mesh
  31477. * @param name defines the mesh name
  31478. * @param newParent defines the new mesh parent
  31479. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31480. * @returns the new mesh
  31481. */
  31482. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31483. /**
  31484. * Disposes all the submeshes of the current meshnp
  31485. * @returns the current mesh
  31486. */
  31487. releaseSubMeshes(): AbstractMesh;
  31488. /**
  31489. * Releases resources associated with this abstract mesh.
  31490. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31491. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31492. */
  31493. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31494. /**
  31495. * Adds the passed mesh as a child to the current mesh
  31496. * @param mesh defines the child mesh
  31497. * @returns the current mesh
  31498. */
  31499. addChild(mesh: AbstractMesh): AbstractMesh;
  31500. /**
  31501. * Removes the passed mesh from the current mesh children list
  31502. * @param mesh defines the child mesh
  31503. * @returns the current mesh
  31504. */
  31505. removeChild(mesh: AbstractMesh): AbstractMesh;
  31506. /** @hidden */
  31507. private _initFacetData;
  31508. /**
  31509. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31510. * This method can be called within the render loop.
  31511. * 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
  31512. * @returns the current mesh
  31513. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31514. */
  31515. updateFacetData(): AbstractMesh;
  31516. /**
  31517. * Returns the facetLocalNormals array.
  31518. * The normals are expressed in the mesh local spac
  31519. * @returns an array of Vector3
  31520. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31521. */
  31522. getFacetLocalNormals(): Vector3[];
  31523. /**
  31524. * Returns the facetLocalPositions array.
  31525. * The facet positions are expressed in the mesh local space
  31526. * @returns an array of Vector3
  31527. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31528. */
  31529. getFacetLocalPositions(): Vector3[];
  31530. /**
  31531. * Returns the facetLocalPartioning array
  31532. * @returns an array of array of numbers
  31533. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31534. */
  31535. getFacetLocalPartitioning(): number[][];
  31536. /**
  31537. * Returns the i-th facet position in the world system.
  31538. * This method allocates a new Vector3 per call
  31539. * @param i defines the facet index
  31540. * @returns a new Vector3
  31541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31542. */
  31543. getFacetPosition(i: number): Vector3;
  31544. /**
  31545. * Sets the reference Vector3 with the i-th facet position in the world system
  31546. * @param i defines the facet index
  31547. * @param ref defines the target vector
  31548. * @returns the current mesh
  31549. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31550. */
  31551. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31552. /**
  31553. * Returns the i-th facet normal in the world system.
  31554. * This method allocates a new Vector3 per call
  31555. * @param i defines the facet index
  31556. * @returns a new Vector3
  31557. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31558. */
  31559. getFacetNormal(i: number): Vector3;
  31560. /**
  31561. * Sets the reference Vector3 with the i-th facet normal in the world system
  31562. * @param i defines the facet index
  31563. * @param ref defines the target vector
  31564. * @returns the current mesh
  31565. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31566. */
  31567. getFacetNormalToRef(i: number, ref: Vector3): this;
  31568. /**
  31569. * 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)
  31570. * @param x defines x coordinate
  31571. * @param y defines y coordinate
  31572. * @param z defines z coordinate
  31573. * @returns the array of facet indexes
  31574. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31575. */
  31576. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31577. /**
  31578. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31579. * @param projected sets as the (x,y,z) world projection on the facet
  31580. * @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
  31581. * @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
  31582. * @param x defines x coordinate
  31583. * @param y defines y coordinate
  31584. * @param z defines z coordinate
  31585. * @returns the face index if found (or null instead)
  31586. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31587. */
  31588. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31589. /**
  31590. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31591. * @param projected sets as the (x,y,z) local projection on the facet
  31592. * @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
  31593. * @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
  31594. * @param x defines x coordinate
  31595. * @param y defines y coordinate
  31596. * @param z defines z coordinate
  31597. * @returns the face index if found (or null instead)
  31598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31599. */
  31600. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31601. /**
  31602. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31603. * @returns the parameters
  31604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31605. */
  31606. getFacetDataParameters(): any;
  31607. /**
  31608. * Disables the feature FacetData and frees the related memory
  31609. * @returns the current mesh
  31610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31611. */
  31612. disableFacetData(): AbstractMesh;
  31613. /**
  31614. * Updates the AbstractMesh indices array
  31615. * @param indices defines the data source
  31616. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31617. * @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)
  31618. * @returns the current mesh
  31619. */
  31620. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31621. /**
  31622. * Creates new normals data for the mesh
  31623. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31624. * @returns the current mesh
  31625. */
  31626. createNormals(updatable: boolean): AbstractMesh;
  31627. /**
  31628. * Align the mesh with a normal
  31629. * @param normal defines the normal to use
  31630. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31631. * @returns the current mesh
  31632. */
  31633. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31634. /** @hidden */
  31635. _checkOcclusionQuery(): boolean;
  31636. /**
  31637. * Disables the mesh edge rendering mode
  31638. * @returns the currentAbstractMesh
  31639. */
  31640. disableEdgesRendering(): AbstractMesh;
  31641. /**
  31642. * Enables the edge rendering mode on the mesh.
  31643. * This mode makes the mesh edges visible
  31644. * @param epsilon defines the maximal distance between two angles to detect a face
  31645. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31646. * @returns the currentAbstractMesh
  31647. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31648. */
  31649. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31650. }
  31651. }
  31652. declare module BABYLON {
  31653. /**
  31654. * Interface used to define ActionEvent
  31655. */
  31656. export interface IActionEvent {
  31657. /** The mesh or sprite that triggered the action */
  31658. source: any;
  31659. /** The X mouse cursor position at the time of the event */
  31660. pointerX: number;
  31661. /** The Y mouse cursor position at the time of the event */
  31662. pointerY: number;
  31663. /** The mesh that is currently pointed at (can be null) */
  31664. meshUnderPointer: Nullable<AbstractMesh>;
  31665. /** the original (browser) event that triggered the ActionEvent */
  31666. sourceEvent?: any;
  31667. /** additional data for the event */
  31668. additionalData?: any;
  31669. }
  31670. /**
  31671. * ActionEvent is the event being sent when an action is triggered.
  31672. */
  31673. export class ActionEvent implements IActionEvent {
  31674. /** The mesh or sprite that triggered the action */
  31675. source: any;
  31676. /** The X mouse cursor position at the time of the event */
  31677. pointerX: number;
  31678. /** The Y mouse cursor position at the time of the event */
  31679. pointerY: number;
  31680. /** The mesh that is currently pointed at (can be null) */
  31681. meshUnderPointer: Nullable<AbstractMesh>;
  31682. /** the original (browser) event that triggered the ActionEvent */
  31683. sourceEvent?: any;
  31684. /** additional data for the event */
  31685. additionalData?: any;
  31686. /**
  31687. * Creates a new ActionEvent
  31688. * @param source The mesh or sprite that triggered the action
  31689. * @param pointerX The X mouse cursor position at the time of the event
  31690. * @param pointerY The Y mouse cursor position at the time of the event
  31691. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31692. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31693. * @param additionalData additional data for the event
  31694. */
  31695. constructor(
  31696. /** The mesh or sprite that triggered the action */
  31697. source: any,
  31698. /** The X mouse cursor position at the time of the event */
  31699. pointerX: number,
  31700. /** The Y mouse cursor position at the time of the event */
  31701. pointerY: number,
  31702. /** The mesh that is currently pointed at (can be null) */
  31703. meshUnderPointer: Nullable<AbstractMesh>,
  31704. /** the original (browser) event that triggered the ActionEvent */
  31705. sourceEvent?: any,
  31706. /** additional data for the event */
  31707. additionalData?: any);
  31708. /**
  31709. * Helper function to auto-create an ActionEvent from a source mesh.
  31710. * @param source The source mesh that triggered the event
  31711. * @param evt The original (browser) event
  31712. * @param additionalData additional data for the event
  31713. * @returns the new ActionEvent
  31714. */
  31715. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31716. /**
  31717. * Helper function to auto-create an ActionEvent from a source sprite
  31718. * @param source The source sprite that triggered the event
  31719. * @param scene Scene associated with the sprite
  31720. * @param evt The original (browser) event
  31721. * @param additionalData additional data for the event
  31722. * @returns the new ActionEvent
  31723. */
  31724. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31725. /**
  31726. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31727. * @param scene the scene where the event occurred
  31728. * @param evt The original (browser) event
  31729. * @returns the new ActionEvent
  31730. */
  31731. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31732. /**
  31733. * Helper function to auto-create an ActionEvent from a primitive
  31734. * @param prim defines the target primitive
  31735. * @param pointerPos defines the pointer position
  31736. * @param evt The original (browser) event
  31737. * @param additionalData additional data for the event
  31738. * @returns the new ActionEvent
  31739. */
  31740. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31741. }
  31742. }
  31743. declare module BABYLON {
  31744. /**
  31745. * Abstract class used to decouple action Manager from scene and meshes.
  31746. * Do not instantiate.
  31747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31748. */
  31749. export abstract class AbstractActionManager implements IDisposable {
  31750. /** Gets the list of active triggers */
  31751. static Triggers: {
  31752. [key: string]: number;
  31753. };
  31754. /** Gets the cursor to use when hovering items */
  31755. hoverCursor: string;
  31756. /** Gets the list of actions */
  31757. actions: IAction[];
  31758. /**
  31759. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31760. */
  31761. isRecursive: boolean;
  31762. /**
  31763. * Releases all associated resources
  31764. */
  31765. abstract dispose(): void;
  31766. /**
  31767. * Does this action manager has pointer triggers
  31768. */
  31769. abstract get hasPointerTriggers(): boolean;
  31770. /**
  31771. * Does this action manager has pick triggers
  31772. */
  31773. abstract get hasPickTriggers(): boolean;
  31774. /**
  31775. * Process a specific trigger
  31776. * @param trigger defines the trigger to process
  31777. * @param evt defines the event details to be processed
  31778. */
  31779. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31780. /**
  31781. * Does this action manager handles actions of any of the given triggers
  31782. * @param triggers defines the triggers to be tested
  31783. * @return a boolean indicating whether one (or more) of the triggers is handled
  31784. */
  31785. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31786. /**
  31787. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31788. * speed.
  31789. * @param triggerA defines the trigger to be tested
  31790. * @param triggerB defines the trigger to be tested
  31791. * @return a boolean indicating whether one (or more) of the triggers is handled
  31792. */
  31793. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31794. /**
  31795. * Does this action manager handles actions of a given trigger
  31796. * @param trigger defines the trigger to be tested
  31797. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31798. * @return whether the trigger is handled
  31799. */
  31800. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31801. /**
  31802. * Serialize this manager to a JSON object
  31803. * @param name defines the property name to store this manager
  31804. * @returns a JSON representation of this manager
  31805. */
  31806. abstract serialize(name: string): any;
  31807. /**
  31808. * Registers an action to this action manager
  31809. * @param action defines the action to be registered
  31810. * @return the action amended (prepared) after registration
  31811. */
  31812. abstract registerAction(action: IAction): Nullable<IAction>;
  31813. /**
  31814. * Unregisters an action to this action manager
  31815. * @param action defines the action to be unregistered
  31816. * @return a boolean indicating whether the action has been unregistered
  31817. */
  31818. abstract unregisterAction(action: IAction): Boolean;
  31819. /**
  31820. * Does exist one action manager with at least one trigger
  31821. **/
  31822. static get HasTriggers(): boolean;
  31823. /**
  31824. * Does exist one action manager with at least one pick trigger
  31825. **/
  31826. static get HasPickTriggers(): boolean;
  31827. /**
  31828. * Does exist one action manager that handles actions of a given trigger
  31829. * @param trigger defines the trigger to be tested
  31830. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  31831. **/
  31832. static HasSpecificTrigger(trigger: number): boolean;
  31833. }
  31834. }
  31835. declare module BABYLON {
  31836. /**
  31837. * Defines how a node can be built from a string name.
  31838. */
  31839. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  31840. /**
  31841. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  31842. */
  31843. export class Node implements IBehaviorAware<Node> {
  31844. /** @hidden */
  31845. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  31846. private static _NodeConstructors;
  31847. /**
  31848. * Add a new node constructor
  31849. * @param type defines the type name of the node to construct
  31850. * @param constructorFunc defines the constructor function
  31851. */
  31852. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  31853. /**
  31854. * Returns a node constructor based on type name
  31855. * @param type defines the type name
  31856. * @param name defines the new node name
  31857. * @param scene defines the hosting scene
  31858. * @param options defines optional options to transmit to constructors
  31859. * @returns the new constructor or null
  31860. */
  31861. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  31862. /**
  31863. * Gets or sets the name of the node
  31864. */
  31865. name: string;
  31866. /**
  31867. * Gets or sets the id of the node
  31868. */
  31869. id: string;
  31870. /**
  31871. * Gets or sets the unique id of the node
  31872. */
  31873. uniqueId: number;
  31874. /**
  31875. * Gets or sets a string used to store user defined state for the node
  31876. */
  31877. state: string;
  31878. /**
  31879. * Gets or sets an object used to store user defined information for the node
  31880. */
  31881. metadata: any;
  31882. /**
  31883. * For internal use only. Please do not use.
  31884. */
  31885. reservedDataStore: any;
  31886. /**
  31887. * List of inspectable custom properties (used by the Inspector)
  31888. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  31889. */
  31890. inspectableCustomProperties: IInspectable[];
  31891. private _doNotSerialize;
  31892. /**
  31893. * Gets or sets a boolean used to define if the node must be serialized
  31894. */
  31895. get doNotSerialize(): boolean;
  31896. set doNotSerialize(value: boolean);
  31897. /** @hidden */
  31898. _isDisposed: boolean;
  31899. /**
  31900. * Gets a list of Animations associated with the node
  31901. */
  31902. animations: Animation[];
  31903. protected _ranges: {
  31904. [name: string]: Nullable<AnimationRange>;
  31905. };
  31906. /**
  31907. * Callback raised when the node is ready to be used
  31908. */
  31909. onReady: Nullable<(node: Node) => void>;
  31910. private _isEnabled;
  31911. private _isParentEnabled;
  31912. private _isReady;
  31913. /** @hidden */
  31914. _currentRenderId: number;
  31915. private _parentUpdateId;
  31916. /** @hidden */
  31917. _childUpdateId: number;
  31918. /** @hidden */
  31919. _waitingParentId: Nullable<string>;
  31920. /** @hidden */
  31921. _scene: Scene;
  31922. /** @hidden */
  31923. _cache: any;
  31924. private _parentNode;
  31925. private _children;
  31926. /** @hidden */
  31927. _worldMatrix: Matrix;
  31928. /** @hidden */
  31929. _worldMatrixDeterminant: number;
  31930. /** @hidden */
  31931. _worldMatrixDeterminantIsDirty: boolean;
  31932. /** @hidden */
  31933. private _sceneRootNodesIndex;
  31934. /**
  31935. * Gets a boolean indicating if the node has been disposed
  31936. * @returns true if the node was disposed
  31937. */
  31938. isDisposed(): boolean;
  31939. /**
  31940. * Gets or sets the parent of the node (without keeping the current position in the scene)
  31941. * @see https://doc.babylonjs.com/how_to/parenting
  31942. */
  31943. set parent(parent: Nullable<Node>);
  31944. get parent(): Nullable<Node>;
  31945. /** @hidden */
  31946. _addToSceneRootNodes(): void;
  31947. /** @hidden */
  31948. _removeFromSceneRootNodes(): void;
  31949. private _animationPropertiesOverride;
  31950. /**
  31951. * Gets or sets the animation properties override
  31952. */
  31953. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31954. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31955. /**
  31956. * Gets a string idenfifying the name of the class
  31957. * @returns "Node" string
  31958. */
  31959. getClassName(): string;
  31960. /** @hidden */
  31961. readonly _isNode: boolean;
  31962. /**
  31963. * An event triggered when the mesh is disposed
  31964. */
  31965. onDisposeObservable: Observable<Node>;
  31966. private _onDisposeObserver;
  31967. /**
  31968. * Sets a callback that will be raised when the node will be disposed
  31969. */
  31970. set onDispose(callback: () => void);
  31971. /**
  31972. * Creates a new Node
  31973. * @param name the name and id to be given to this node
  31974. * @param scene the scene this node will be added to
  31975. */
  31976. constructor(name: string, scene?: Nullable<Scene>);
  31977. /**
  31978. * Gets the scene of the node
  31979. * @returns a scene
  31980. */
  31981. getScene(): Scene;
  31982. /**
  31983. * Gets the engine of the node
  31984. * @returns a Engine
  31985. */
  31986. getEngine(): Engine;
  31987. private _behaviors;
  31988. /**
  31989. * Attach a behavior to the node
  31990. * @see http://doc.babylonjs.com/features/behaviour
  31991. * @param behavior defines the behavior to attach
  31992. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  31993. * @returns the current Node
  31994. */
  31995. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  31996. /**
  31997. * Remove an attached behavior
  31998. * @see http://doc.babylonjs.com/features/behaviour
  31999. * @param behavior defines the behavior to attach
  32000. * @returns the current Node
  32001. */
  32002. removeBehavior(behavior: Behavior<Node>): Node;
  32003. /**
  32004. * Gets the list of attached behaviors
  32005. * @see http://doc.babylonjs.com/features/behaviour
  32006. */
  32007. get behaviors(): Behavior<Node>[];
  32008. /**
  32009. * Gets an attached behavior by name
  32010. * @param name defines the name of the behavior to look for
  32011. * @see http://doc.babylonjs.com/features/behaviour
  32012. * @returns null if behavior was not found else the requested behavior
  32013. */
  32014. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32015. /**
  32016. * Returns the latest update of the World matrix
  32017. * @returns a Matrix
  32018. */
  32019. getWorldMatrix(): Matrix;
  32020. /** @hidden */
  32021. _getWorldMatrixDeterminant(): number;
  32022. /**
  32023. * Returns directly the latest state of the mesh World matrix.
  32024. * A Matrix is returned.
  32025. */
  32026. get worldMatrixFromCache(): Matrix;
  32027. /** @hidden */
  32028. _initCache(): void;
  32029. /** @hidden */
  32030. updateCache(force?: boolean): void;
  32031. /** @hidden */
  32032. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32033. /** @hidden */
  32034. _updateCache(ignoreParentClass?: boolean): void;
  32035. /** @hidden */
  32036. _isSynchronized(): boolean;
  32037. /** @hidden */
  32038. _markSyncedWithParent(): void;
  32039. /** @hidden */
  32040. isSynchronizedWithParent(): boolean;
  32041. /** @hidden */
  32042. isSynchronized(): boolean;
  32043. /**
  32044. * Is this node ready to be used/rendered
  32045. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32046. * @return true if the node is ready
  32047. */
  32048. isReady(completeCheck?: boolean): boolean;
  32049. /**
  32050. * Is this node enabled?
  32051. * 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
  32052. * @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
  32053. * @return whether this node (and its parent) is enabled
  32054. */
  32055. isEnabled(checkAncestors?: boolean): boolean;
  32056. /** @hidden */
  32057. protected _syncParentEnabledState(): void;
  32058. /**
  32059. * Set the enabled state of this node
  32060. * @param value defines the new enabled state
  32061. */
  32062. setEnabled(value: boolean): void;
  32063. /**
  32064. * Is this node a descendant of the given node?
  32065. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32066. * @param ancestor defines the parent node to inspect
  32067. * @returns a boolean indicating if this node is a descendant of the given node
  32068. */
  32069. isDescendantOf(ancestor: Node): boolean;
  32070. /** @hidden */
  32071. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32072. /**
  32073. * Will return all nodes that have this node as ascendant
  32074. * @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
  32075. * @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
  32076. * @return all children nodes of all types
  32077. */
  32078. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32079. /**
  32080. * Get all child-meshes of this node
  32081. * @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)
  32082. * @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
  32083. * @returns an array of AbstractMesh
  32084. */
  32085. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32086. /**
  32087. * Get all direct children of this node
  32088. * @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
  32089. * @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)
  32090. * @returns an array of Node
  32091. */
  32092. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32093. /** @hidden */
  32094. _setReady(state: boolean): void;
  32095. /**
  32096. * Get an animation by name
  32097. * @param name defines the name of the animation to look for
  32098. * @returns null if not found else the requested animation
  32099. */
  32100. getAnimationByName(name: string): Nullable<Animation>;
  32101. /**
  32102. * Creates an animation range for this node
  32103. * @param name defines the name of the range
  32104. * @param from defines the starting key
  32105. * @param to defines the end key
  32106. */
  32107. createAnimationRange(name: string, from: number, to: number): void;
  32108. /**
  32109. * Delete a specific animation range
  32110. * @param name defines the name of the range to delete
  32111. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32112. */
  32113. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32114. /**
  32115. * Get an animation range by name
  32116. * @param name defines the name of the animation range to look for
  32117. * @returns null if not found else the requested animation range
  32118. */
  32119. getAnimationRange(name: string): Nullable<AnimationRange>;
  32120. /**
  32121. * Gets the list of all animation ranges defined on this node
  32122. * @returns an array
  32123. */
  32124. getAnimationRanges(): Nullable<AnimationRange>[];
  32125. /**
  32126. * Will start the animation sequence
  32127. * @param name defines the range frames for animation sequence
  32128. * @param loop defines if the animation should loop (false by default)
  32129. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32130. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32131. * @returns the object created for this animation. If range does not exist, it will return null
  32132. */
  32133. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32134. /**
  32135. * Serialize animation ranges into a JSON compatible object
  32136. * @returns serialization object
  32137. */
  32138. serializeAnimationRanges(): any;
  32139. /**
  32140. * Computes the world matrix of the node
  32141. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32142. * @returns the world matrix
  32143. */
  32144. computeWorldMatrix(force?: boolean): Matrix;
  32145. /**
  32146. * Releases resources associated with this node.
  32147. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32148. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32149. */
  32150. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32151. /**
  32152. * Parse animation range data from a serialization object and store them into a given node
  32153. * @param node defines where to store the animation ranges
  32154. * @param parsedNode defines the serialization object to read data from
  32155. * @param scene defines the hosting scene
  32156. */
  32157. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32158. /**
  32159. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32160. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32161. * @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
  32162. * @returns the new bounding vectors
  32163. */
  32164. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32165. min: Vector3;
  32166. max: Vector3;
  32167. };
  32168. }
  32169. }
  32170. declare module BABYLON {
  32171. /**
  32172. * @hidden
  32173. */
  32174. export class _IAnimationState {
  32175. key: number;
  32176. repeatCount: number;
  32177. workValue?: any;
  32178. loopMode?: number;
  32179. offsetValue?: any;
  32180. highLimitValue?: any;
  32181. }
  32182. /**
  32183. * Class used to store any kind of animation
  32184. */
  32185. export class Animation {
  32186. /**Name of the animation */
  32187. name: string;
  32188. /**Property to animate */
  32189. targetProperty: string;
  32190. /**The frames per second of the animation */
  32191. framePerSecond: number;
  32192. /**The data type of the animation */
  32193. dataType: number;
  32194. /**The loop mode of the animation */
  32195. loopMode?: number | undefined;
  32196. /**Specifies if blending should be enabled */
  32197. enableBlending?: boolean | undefined;
  32198. /**
  32199. * Use matrix interpolation instead of using direct key value when animating matrices
  32200. */
  32201. static AllowMatricesInterpolation: boolean;
  32202. /**
  32203. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32204. */
  32205. static AllowMatrixDecomposeForInterpolation: boolean;
  32206. /**
  32207. * Stores the key frames of the animation
  32208. */
  32209. private _keys;
  32210. /**
  32211. * Stores the easing function of the animation
  32212. */
  32213. private _easingFunction;
  32214. /**
  32215. * @hidden Internal use only
  32216. */
  32217. _runtimeAnimations: RuntimeAnimation[];
  32218. /**
  32219. * The set of event that will be linked to this animation
  32220. */
  32221. private _events;
  32222. /**
  32223. * Stores an array of target property paths
  32224. */
  32225. targetPropertyPath: string[];
  32226. /**
  32227. * Stores the blending speed of the animation
  32228. */
  32229. blendingSpeed: number;
  32230. /**
  32231. * Stores the animation ranges for the animation
  32232. */
  32233. private _ranges;
  32234. /**
  32235. * @hidden Internal use
  32236. */
  32237. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32238. /**
  32239. * Sets up an animation
  32240. * @param property The property to animate
  32241. * @param animationType The animation type to apply
  32242. * @param framePerSecond The frames per second of the animation
  32243. * @param easingFunction The easing function used in the animation
  32244. * @returns The created animation
  32245. */
  32246. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32247. /**
  32248. * Create and start an animation on a node
  32249. * @param name defines the name of the global animation that will be run on all nodes
  32250. * @param node defines the root node where the animation will take place
  32251. * @param targetProperty defines property to animate
  32252. * @param framePerSecond defines the number of frame per second yo use
  32253. * @param totalFrame defines the number of frames in total
  32254. * @param from defines the initial value
  32255. * @param to defines the final value
  32256. * @param loopMode defines which loop mode you want to use (off by default)
  32257. * @param easingFunction defines the easing function to use (linear by default)
  32258. * @param onAnimationEnd defines the callback to call when animation end
  32259. * @returns the animatable created for this animation
  32260. */
  32261. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32262. /**
  32263. * Create and start an animation on a node and its descendants
  32264. * @param name defines the name of the global animation that will be run on all nodes
  32265. * @param node defines the root node where the animation will take place
  32266. * @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
  32267. * @param targetProperty defines property to animate
  32268. * @param framePerSecond defines the number of frame per second to use
  32269. * @param totalFrame defines the number of frames in total
  32270. * @param from defines the initial value
  32271. * @param to defines the final value
  32272. * @param loopMode defines which loop mode you want to use (off by default)
  32273. * @param easingFunction defines the easing function to use (linear by default)
  32274. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32275. * @returns the list of animatables created for all nodes
  32276. * @example https://www.babylonjs-playground.com/#MH0VLI
  32277. */
  32278. 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[]>;
  32279. /**
  32280. * Creates a new animation, merges it with the existing animations and starts it
  32281. * @param name Name of the animation
  32282. * @param node Node which contains the scene that begins the animations
  32283. * @param targetProperty Specifies which property to animate
  32284. * @param framePerSecond The frames per second of the animation
  32285. * @param totalFrame The total number of frames
  32286. * @param from The frame at the beginning of the animation
  32287. * @param to The frame at the end of the animation
  32288. * @param loopMode Specifies the loop mode of the animation
  32289. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32290. * @param onAnimationEnd Callback to run once the animation is complete
  32291. * @returns Nullable animation
  32292. */
  32293. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32294. /**
  32295. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32296. * @param sourceAnimation defines the Animation containing keyframes to convert
  32297. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32298. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32299. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32300. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32301. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32302. */
  32303. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32304. /**
  32305. * Transition property of an host to the target Value
  32306. * @param property The property to transition
  32307. * @param targetValue The target Value of the property
  32308. * @param host The object where the property to animate belongs
  32309. * @param scene Scene used to run the animation
  32310. * @param frameRate Framerate (in frame/s) to use
  32311. * @param transition The transition type we want to use
  32312. * @param duration The duration of the animation, in milliseconds
  32313. * @param onAnimationEnd Callback trigger at the end of the animation
  32314. * @returns Nullable animation
  32315. */
  32316. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32317. /**
  32318. * Return the array of runtime animations currently using this animation
  32319. */
  32320. get runtimeAnimations(): RuntimeAnimation[];
  32321. /**
  32322. * Specifies if any of the runtime animations are currently running
  32323. */
  32324. get hasRunningRuntimeAnimations(): boolean;
  32325. /**
  32326. * Initializes the animation
  32327. * @param name Name of the animation
  32328. * @param targetProperty Property to animate
  32329. * @param framePerSecond The frames per second of the animation
  32330. * @param dataType The data type of the animation
  32331. * @param loopMode The loop mode of the animation
  32332. * @param enableBlending Specifies if blending should be enabled
  32333. */
  32334. constructor(
  32335. /**Name of the animation */
  32336. name: string,
  32337. /**Property to animate */
  32338. targetProperty: string,
  32339. /**The frames per second of the animation */
  32340. framePerSecond: number,
  32341. /**The data type of the animation */
  32342. dataType: number,
  32343. /**The loop mode of the animation */
  32344. loopMode?: number | undefined,
  32345. /**Specifies if blending should be enabled */
  32346. enableBlending?: boolean | undefined);
  32347. /**
  32348. * Converts the animation to a string
  32349. * @param fullDetails support for multiple levels of logging within scene loading
  32350. * @returns String form of the animation
  32351. */
  32352. toString(fullDetails?: boolean): string;
  32353. /**
  32354. * Add an event to this animation
  32355. * @param event Event to add
  32356. */
  32357. addEvent(event: AnimationEvent): void;
  32358. /**
  32359. * Remove all events found at the given frame
  32360. * @param frame The frame to remove events from
  32361. */
  32362. removeEvents(frame: number): void;
  32363. /**
  32364. * Retrieves all the events from the animation
  32365. * @returns Events from the animation
  32366. */
  32367. getEvents(): AnimationEvent[];
  32368. /**
  32369. * Creates an animation range
  32370. * @param name Name of the animation range
  32371. * @param from Starting frame of the animation range
  32372. * @param to Ending frame of the animation
  32373. */
  32374. createRange(name: string, from: number, to: number): void;
  32375. /**
  32376. * Deletes an animation range by name
  32377. * @param name Name of the animation range to delete
  32378. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32379. */
  32380. deleteRange(name: string, deleteFrames?: boolean): void;
  32381. /**
  32382. * Gets the animation range by name, or null if not defined
  32383. * @param name Name of the animation range
  32384. * @returns Nullable animation range
  32385. */
  32386. getRange(name: string): Nullable<AnimationRange>;
  32387. /**
  32388. * Gets the key frames from the animation
  32389. * @returns The key frames of the animation
  32390. */
  32391. getKeys(): Array<IAnimationKey>;
  32392. /**
  32393. * Gets the highest frame rate of the animation
  32394. * @returns Highest frame rate of the animation
  32395. */
  32396. getHighestFrame(): number;
  32397. /**
  32398. * Gets the easing function of the animation
  32399. * @returns Easing function of the animation
  32400. */
  32401. getEasingFunction(): IEasingFunction;
  32402. /**
  32403. * Sets the easing function of the animation
  32404. * @param easingFunction A custom mathematical formula for animation
  32405. */
  32406. setEasingFunction(easingFunction: EasingFunction): void;
  32407. /**
  32408. * Interpolates a scalar linearly
  32409. * @param startValue Start value of the animation curve
  32410. * @param endValue End value of the animation curve
  32411. * @param gradient Scalar amount to interpolate
  32412. * @returns Interpolated scalar value
  32413. */
  32414. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32415. /**
  32416. * Interpolates a scalar cubically
  32417. * @param startValue Start value of the animation curve
  32418. * @param outTangent End tangent of the animation
  32419. * @param endValue End value of the animation curve
  32420. * @param inTangent Start tangent of the animation curve
  32421. * @param gradient Scalar amount to interpolate
  32422. * @returns Interpolated scalar value
  32423. */
  32424. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32425. /**
  32426. * Interpolates a quaternion using a spherical linear interpolation
  32427. * @param startValue Start value of the animation curve
  32428. * @param endValue End value of the animation curve
  32429. * @param gradient Scalar amount to interpolate
  32430. * @returns Interpolated quaternion value
  32431. */
  32432. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32433. /**
  32434. * Interpolates a quaternion cubically
  32435. * @param startValue Start value of the animation curve
  32436. * @param outTangent End tangent of the animation curve
  32437. * @param endValue End value of the animation curve
  32438. * @param inTangent Start tangent of the animation curve
  32439. * @param gradient Scalar amount to interpolate
  32440. * @returns Interpolated quaternion value
  32441. */
  32442. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32443. /**
  32444. * Interpolates a Vector3 linearl
  32445. * @param startValue Start value of the animation curve
  32446. * @param endValue End value of the animation curve
  32447. * @param gradient Scalar amount to interpolate
  32448. * @returns Interpolated scalar value
  32449. */
  32450. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32451. /**
  32452. * Interpolates a Vector3 cubically
  32453. * @param startValue Start value of the animation curve
  32454. * @param outTangent End tangent of the animation
  32455. * @param endValue End value of the animation curve
  32456. * @param inTangent Start tangent of the animation curve
  32457. * @param gradient Scalar amount to interpolate
  32458. * @returns InterpolatedVector3 value
  32459. */
  32460. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32461. /**
  32462. * Interpolates a Vector2 linearly
  32463. * @param startValue Start value of the animation curve
  32464. * @param endValue End value of the animation curve
  32465. * @param gradient Scalar amount to interpolate
  32466. * @returns Interpolated Vector2 value
  32467. */
  32468. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32469. /**
  32470. * Interpolates a Vector2 cubically
  32471. * @param startValue Start value of the animation curve
  32472. * @param outTangent End tangent of the animation
  32473. * @param endValue End value of the animation curve
  32474. * @param inTangent Start tangent of the animation curve
  32475. * @param gradient Scalar amount to interpolate
  32476. * @returns Interpolated Vector2 value
  32477. */
  32478. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32479. /**
  32480. * Interpolates a size linearly
  32481. * @param startValue Start value of the animation curve
  32482. * @param endValue End value of the animation curve
  32483. * @param gradient Scalar amount to interpolate
  32484. * @returns Interpolated Size value
  32485. */
  32486. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32487. /**
  32488. * Interpolates a Color3 linearly
  32489. * @param startValue Start value of the animation curve
  32490. * @param endValue End value of the animation curve
  32491. * @param gradient Scalar amount to interpolate
  32492. * @returns Interpolated Color3 value
  32493. */
  32494. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32495. /**
  32496. * Interpolates a Color4 linearly
  32497. * @param startValue Start value of the animation curve
  32498. * @param endValue End value of the animation curve
  32499. * @param gradient Scalar amount to interpolate
  32500. * @returns Interpolated Color3 value
  32501. */
  32502. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32503. /**
  32504. * @hidden Internal use only
  32505. */
  32506. _getKeyValue(value: any): any;
  32507. /**
  32508. * @hidden Internal use only
  32509. */
  32510. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32511. /**
  32512. * Defines the function to use to interpolate matrices
  32513. * @param startValue defines the start matrix
  32514. * @param endValue defines the end matrix
  32515. * @param gradient defines the gradient between both matrices
  32516. * @param result defines an optional target matrix where to store the interpolation
  32517. * @returns the interpolated matrix
  32518. */
  32519. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32520. /**
  32521. * Makes a copy of the animation
  32522. * @returns Cloned animation
  32523. */
  32524. clone(): Animation;
  32525. /**
  32526. * Sets the key frames of the animation
  32527. * @param values The animation key frames to set
  32528. */
  32529. setKeys(values: Array<IAnimationKey>): void;
  32530. /**
  32531. * Serializes the animation to an object
  32532. * @returns Serialized object
  32533. */
  32534. serialize(): any;
  32535. /**
  32536. * Float animation type
  32537. */
  32538. static readonly ANIMATIONTYPE_FLOAT: number;
  32539. /**
  32540. * Vector3 animation type
  32541. */
  32542. static readonly ANIMATIONTYPE_VECTOR3: number;
  32543. /**
  32544. * Quaternion animation type
  32545. */
  32546. static readonly ANIMATIONTYPE_QUATERNION: number;
  32547. /**
  32548. * Matrix animation type
  32549. */
  32550. static readonly ANIMATIONTYPE_MATRIX: number;
  32551. /**
  32552. * Color3 animation type
  32553. */
  32554. static readonly ANIMATIONTYPE_COLOR3: number;
  32555. /**
  32556. * Color3 animation type
  32557. */
  32558. static readonly ANIMATIONTYPE_COLOR4: number;
  32559. /**
  32560. * Vector2 animation type
  32561. */
  32562. static readonly ANIMATIONTYPE_VECTOR2: number;
  32563. /**
  32564. * Size animation type
  32565. */
  32566. static readonly ANIMATIONTYPE_SIZE: number;
  32567. /**
  32568. * Relative Loop Mode
  32569. */
  32570. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32571. /**
  32572. * Cycle Loop Mode
  32573. */
  32574. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32575. /**
  32576. * Constant Loop Mode
  32577. */
  32578. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32579. /** @hidden */
  32580. static _UniversalLerp(left: any, right: any, amount: number): any;
  32581. /**
  32582. * Parses an animation object and creates an animation
  32583. * @param parsedAnimation Parsed animation object
  32584. * @returns Animation object
  32585. */
  32586. static Parse(parsedAnimation: any): Animation;
  32587. /**
  32588. * Appends the serialized animations from the source animations
  32589. * @param source Source containing the animations
  32590. * @param destination Target to store the animations
  32591. */
  32592. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32593. }
  32594. }
  32595. declare module BABYLON {
  32596. /**
  32597. * Interface containing an array of animations
  32598. */
  32599. export interface IAnimatable {
  32600. /**
  32601. * Array of animations
  32602. */
  32603. animations: Nullable<Array<Animation>>;
  32604. }
  32605. }
  32606. declare module BABYLON {
  32607. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32608. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32609. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32610. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32611. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32612. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32613. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32614. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32615. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32616. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32617. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32618. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32619. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32620. /**
  32621. * Decorator used to define property that can be serialized as reference to a camera
  32622. * @param sourceName defines the name of the property to decorate
  32623. */
  32624. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32625. /**
  32626. * Class used to help serialization objects
  32627. */
  32628. export class SerializationHelper {
  32629. /** @hidden */
  32630. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32631. /** @hidden */
  32632. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32633. /** @hidden */
  32634. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32635. /** @hidden */
  32636. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32637. /**
  32638. * Appends the serialized animations from the source animations
  32639. * @param source Source containing the animations
  32640. * @param destination Target to store the animations
  32641. */
  32642. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32643. /**
  32644. * Static function used to serialized a specific entity
  32645. * @param entity defines the entity to serialize
  32646. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32647. * @returns a JSON compatible object representing the serialization of the entity
  32648. */
  32649. static Serialize<T>(entity: T, serializationObject?: any): any;
  32650. /**
  32651. * Creates a new entity from a serialization data object
  32652. * @param creationFunction defines a function used to instanciated the new entity
  32653. * @param source defines the source serialization data
  32654. * @param scene defines the hosting scene
  32655. * @param rootUrl defines the root url for resources
  32656. * @returns a new entity
  32657. */
  32658. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32659. /**
  32660. * Clones an object
  32661. * @param creationFunction defines the function used to instanciate the new object
  32662. * @param source defines the source object
  32663. * @returns the cloned object
  32664. */
  32665. static Clone<T>(creationFunction: () => T, source: T): T;
  32666. /**
  32667. * Instanciates a new object based on a source one (some data will be shared between both object)
  32668. * @param creationFunction defines the function used to instanciate the new object
  32669. * @param source defines the source object
  32670. * @returns the new object
  32671. */
  32672. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32673. }
  32674. }
  32675. declare module BABYLON {
  32676. /**
  32677. * Base class of all the textures in babylon.
  32678. * It groups all the common properties the materials, post process, lights... might need
  32679. * in order to make a correct use of the texture.
  32680. */
  32681. export class BaseTexture implements IAnimatable {
  32682. /**
  32683. * Default anisotropic filtering level for the application.
  32684. * It is set to 4 as a good tradeoff between perf and quality.
  32685. */
  32686. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32687. /**
  32688. * Gets or sets the unique id of the texture
  32689. */
  32690. uniqueId: number;
  32691. /**
  32692. * Define the name of the texture.
  32693. */
  32694. name: string;
  32695. /**
  32696. * Gets or sets an object used to store user defined information.
  32697. */
  32698. metadata: any;
  32699. /**
  32700. * For internal use only. Please do not use.
  32701. */
  32702. reservedDataStore: any;
  32703. private _hasAlpha;
  32704. /**
  32705. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32706. */
  32707. set hasAlpha(value: boolean);
  32708. get hasAlpha(): boolean;
  32709. /**
  32710. * Defines if the alpha value should be determined via the rgb values.
  32711. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32712. */
  32713. getAlphaFromRGB: boolean;
  32714. /**
  32715. * Intensity or strength of the texture.
  32716. * It is commonly used by materials to fine tune the intensity of the texture
  32717. */
  32718. level: number;
  32719. /**
  32720. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32721. * This is part of the texture as textures usually maps to one uv set.
  32722. */
  32723. coordinatesIndex: number;
  32724. private _coordinatesMode;
  32725. /**
  32726. * How a texture is mapped.
  32727. *
  32728. * | Value | Type | Description |
  32729. * | ----- | ----------------------------------- | ----------- |
  32730. * | 0 | EXPLICIT_MODE | |
  32731. * | 1 | SPHERICAL_MODE | |
  32732. * | 2 | PLANAR_MODE | |
  32733. * | 3 | CUBIC_MODE | |
  32734. * | 4 | PROJECTION_MODE | |
  32735. * | 5 | SKYBOX_MODE | |
  32736. * | 6 | INVCUBIC_MODE | |
  32737. * | 7 | EQUIRECTANGULAR_MODE | |
  32738. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32739. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32740. */
  32741. set coordinatesMode(value: number);
  32742. get coordinatesMode(): number;
  32743. /**
  32744. * | Value | Type | Description |
  32745. * | ----- | ------------------ | ----------- |
  32746. * | 0 | CLAMP_ADDRESSMODE | |
  32747. * | 1 | WRAP_ADDRESSMODE | |
  32748. * | 2 | MIRROR_ADDRESSMODE | |
  32749. */
  32750. wrapU: number;
  32751. /**
  32752. * | Value | Type | Description |
  32753. * | ----- | ------------------ | ----------- |
  32754. * | 0 | CLAMP_ADDRESSMODE | |
  32755. * | 1 | WRAP_ADDRESSMODE | |
  32756. * | 2 | MIRROR_ADDRESSMODE | |
  32757. */
  32758. wrapV: number;
  32759. /**
  32760. * | Value | Type | Description |
  32761. * | ----- | ------------------ | ----------- |
  32762. * | 0 | CLAMP_ADDRESSMODE | |
  32763. * | 1 | WRAP_ADDRESSMODE | |
  32764. * | 2 | MIRROR_ADDRESSMODE | |
  32765. */
  32766. wrapR: number;
  32767. /**
  32768. * With compliant hardware and browser (supporting anisotropic filtering)
  32769. * this defines the level of anisotropic filtering in the texture.
  32770. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32771. */
  32772. anisotropicFilteringLevel: number;
  32773. /**
  32774. * Define if the texture is a cube texture or if false a 2d texture.
  32775. */
  32776. get isCube(): boolean;
  32777. set isCube(value: boolean);
  32778. /**
  32779. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32780. */
  32781. get is3D(): boolean;
  32782. set is3D(value: boolean);
  32783. /**
  32784. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32785. */
  32786. get is2DArray(): boolean;
  32787. set is2DArray(value: boolean);
  32788. /**
  32789. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  32790. * HDR texture are usually stored in linear space.
  32791. * This only impacts the PBR and Background materials
  32792. */
  32793. gammaSpace: boolean;
  32794. /**
  32795. * Gets or sets whether or not the texture contains RGBD data.
  32796. */
  32797. get isRGBD(): boolean;
  32798. set isRGBD(value: boolean);
  32799. /**
  32800. * Is Z inverted in the texture (useful in a cube texture).
  32801. */
  32802. invertZ: boolean;
  32803. /**
  32804. * Are mip maps generated for this texture or not.
  32805. */
  32806. get noMipmap(): boolean;
  32807. /**
  32808. * @hidden
  32809. */
  32810. lodLevelInAlpha: boolean;
  32811. /**
  32812. * With prefiltered texture, defined the offset used during the prefiltering steps.
  32813. */
  32814. get lodGenerationOffset(): number;
  32815. set lodGenerationOffset(value: number);
  32816. /**
  32817. * With prefiltered texture, defined the scale used during the prefiltering steps.
  32818. */
  32819. get lodGenerationScale(): number;
  32820. set lodGenerationScale(value: number);
  32821. /**
  32822. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  32823. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  32824. * average roughness values.
  32825. */
  32826. get linearSpecularLOD(): boolean;
  32827. set linearSpecularLOD(value: boolean);
  32828. /**
  32829. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  32830. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  32831. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  32832. */
  32833. get irradianceTexture(): Nullable<BaseTexture>;
  32834. set irradianceTexture(value: Nullable<BaseTexture>);
  32835. /**
  32836. * Define if the texture is a render target.
  32837. */
  32838. isRenderTarget: boolean;
  32839. /**
  32840. * Define the unique id of the texture in the scene.
  32841. */
  32842. get uid(): string;
  32843. /** @hidden */
  32844. _prefiltered: boolean;
  32845. /**
  32846. * Return a string representation of the texture.
  32847. * @returns the texture as a string
  32848. */
  32849. toString(): string;
  32850. /**
  32851. * Get the class name of the texture.
  32852. * @returns "BaseTexture"
  32853. */
  32854. getClassName(): string;
  32855. /**
  32856. * Define the list of animation attached to the texture.
  32857. */
  32858. animations: Animation[];
  32859. /**
  32860. * An event triggered when the texture is disposed.
  32861. */
  32862. onDisposeObservable: Observable<BaseTexture>;
  32863. private _onDisposeObserver;
  32864. /**
  32865. * Callback triggered when the texture has been disposed.
  32866. * Kept for back compatibility, you can use the onDisposeObservable instead.
  32867. */
  32868. set onDispose(callback: () => void);
  32869. /**
  32870. * Define the current state of the loading sequence when in delayed load mode.
  32871. */
  32872. delayLoadState: number;
  32873. private _scene;
  32874. private _engine;
  32875. /** @hidden */
  32876. _texture: Nullable<InternalTexture>;
  32877. private _uid;
  32878. /**
  32879. * Define if the texture is preventinga material to render or not.
  32880. * If not and the texture is not ready, the engine will use a default black texture instead.
  32881. */
  32882. get isBlocking(): boolean;
  32883. /**
  32884. * Instantiates a new BaseTexture.
  32885. * Base class of all the textures in babylon.
  32886. * It groups all the common properties the materials, post process, lights... might need
  32887. * in order to make a correct use of the texture.
  32888. * @param sceneOrEngine Define the scene or engine the texture blongs to
  32889. */
  32890. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  32891. /**
  32892. * Get the scene the texture belongs to.
  32893. * @returns the scene or null if undefined
  32894. */
  32895. getScene(): Nullable<Scene>;
  32896. /** @hidden */
  32897. protected _getEngine(): Nullable<ThinEngine>;
  32898. /**
  32899. * Get the texture transform matrix used to offset tile the texture for istance.
  32900. * @returns the transformation matrix
  32901. */
  32902. getTextureMatrix(): Matrix;
  32903. /**
  32904. * Get the texture reflection matrix used to rotate/transform the reflection.
  32905. * @returns the reflection matrix
  32906. */
  32907. getReflectionTextureMatrix(): Matrix;
  32908. /**
  32909. * Get the underlying lower level texture from Babylon.
  32910. * @returns the insternal texture
  32911. */
  32912. getInternalTexture(): Nullable<InternalTexture>;
  32913. /**
  32914. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  32915. * @returns true if ready or not blocking
  32916. */
  32917. isReadyOrNotBlocking(): boolean;
  32918. /**
  32919. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  32920. * @returns true if fully ready
  32921. */
  32922. isReady(): boolean;
  32923. private _cachedSize;
  32924. /**
  32925. * Get the size of the texture.
  32926. * @returns the texture size.
  32927. */
  32928. getSize(): ISize;
  32929. /**
  32930. * Get the base size of the texture.
  32931. * It can be different from the size if the texture has been resized for POT for instance
  32932. * @returns the base size
  32933. */
  32934. getBaseSize(): ISize;
  32935. /**
  32936. * Update the sampling mode of the texture.
  32937. * Default is Trilinear mode.
  32938. *
  32939. * | Value | Type | Description |
  32940. * | ----- | ------------------ | ----------- |
  32941. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  32942. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  32943. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  32944. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  32945. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  32946. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  32947. * | 7 | NEAREST_LINEAR | |
  32948. * | 8 | NEAREST_NEAREST | |
  32949. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  32950. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  32951. * | 11 | LINEAR_LINEAR | |
  32952. * | 12 | LINEAR_NEAREST | |
  32953. *
  32954. * > _mag_: magnification filter (close to the viewer)
  32955. * > _min_: minification filter (far from the viewer)
  32956. * > _mip_: filter used between mip map levels
  32957. *@param samplingMode Define the new sampling mode of the texture
  32958. */
  32959. updateSamplingMode(samplingMode: number): void;
  32960. /**
  32961. * Scales the texture if is `canRescale()`
  32962. * @param ratio the resize factor we want to use to rescale
  32963. */
  32964. scale(ratio: number): void;
  32965. /**
  32966. * Get if the texture can rescale.
  32967. */
  32968. get canRescale(): boolean;
  32969. /** @hidden */
  32970. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  32971. /** @hidden */
  32972. _rebuild(): void;
  32973. /**
  32974. * Triggers the load sequence in delayed load mode.
  32975. */
  32976. delayLoad(): void;
  32977. /**
  32978. * Clones the texture.
  32979. * @returns the cloned texture
  32980. */
  32981. clone(): Nullable<BaseTexture>;
  32982. /**
  32983. * Get the texture underlying type (INT, FLOAT...)
  32984. */
  32985. get textureType(): number;
  32986. /**
  32987. * Get the texture underlying format (RGB, RGBA...)
  32988. */
  32989. get textureFormat(): number;
  32990. /**
  32991. * Indicates that textures need to be re-calculated for all materials
  32992. */
  32993. protected _markAllSubMeshesAsTexturesDirty(): void;
  32994. /**
  32995. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  32996. * This will returns an RGBA array buffer containing either in values (0-255) or
  32997. * float values (0-1) depending of the underlying buffer type.
  32998. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  32999. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33000. * @param buffer defines a user defined buffer to fill with data (can be null)
  33001. * @returns The Array buffer containing the pixels data.
  33002. */
  33003. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33004. /**
  33005. * Release and destroy the underlying lower level texture aka internalTexture.
  33006. */
  33007. releaseInternalTexture(): void;
  33008. /** @hidden */
  33009. get _lodTextureHigh(): Nullable<BaseTexture>;
  33010. /** @hidden */
  33011. get _lodTextureMid(): Nullable<BaseTexture>;
  33012. /** @hidden */
  33013. get _lodTextureLow(): Nullable<BaseTexture>;
  33014. /**
  33015. * Dispose the texture and release its associated resources.
  33016. */
  33017. dispose(): void;
  33018. /**
  33019. * Serialize the texture into a JSON representation that can be parsed later on.
  33020. * @returns the JSON representation of the texture
  33021. */
  33022. serialize(): any;
  33023. /**
  33024. * Helper function to be called back once a list of texture contains only ready textures.
  33025. * @param textures Define the list of textures to wait for
  33026. * @param callback Define the callback triggered once the entire list will be ready
  33027. */
  33028. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33029. private static _isScene;
  33030. }
  33031. }
  33032. declare module BABYLON {
  33033. /**
  33034. * Options to be used when creating an effect.
  33035. */
  33036. export interface IEffectCreationOptions {
  33037. /**
  33038. * Atrributes that will be used in the shader.
  33039. */
  33040. attributes: string[];
  33041. /**
  33042. * Uniform varible names that will be set in the shader.
  33043. */
  33044. uniformsNames: string[];
  33045. /**
  33046. * Uniform buffer variable names that will be set in the shader.
  33047. */
  33048. uniformBuffersNames: string[];
  33049. /**
  33050. * Sampler texture variable names that will be set in the shader.
  33051. */
  33052. samplers: string[];
  33053. /**
  33054. * Define statements that will be set in the shader.
  33055. */
  33056. defines: any;
  33057. /**
  33058. * Possible fallbacks for this effect to improve performance when needed.
  33059. */
  33060. fallbacks: Nullable<IEffectFallbacks>;
  33061. /**
  33062. * Callback that will be called when the shader is compiled.
  33063. */
  33064. onCompiled: Nullable<(effect: Effect) => void>;
  33065. /**
  33066. * Callback that will be called if an error occurs during shader compilation.
  33067. */
  33068. onError: Nullable<(effect: Effect, errors: string) => void>;
  33069. /**
  33070. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33071. */
  33072. indexParameters?: any;
  33073. /**
  33074. * Max number of lights that can be used in the shader.
  33075. */
  33076. maxSimultaneousLights?: number;
  33077. /**
  33078. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33079. */
  33080. transformFeedbackVaryings?: Nullable<string[]>;
  33081. /**
  33082. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  33083. */
  33084. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33085. }
  33086. /**
  33087. * Effect containing vertex and fragment shader that can be executed on an object.
  33088. */
  33089. export class Effect implements IDisposable {
  33090. /**
  33091. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33092. */
  33093. static ShadersRepository: string;
  33094. /**
  33095. * Enable logging of the shader code when a compilation error occurs
  33096. */
  33097. static LogShaderCodeOnCompilationError: boolean;
  33098. /**
  33099. * Name of the effect.
  33100. */
  33101. name: any;
  33102. /**
  33103. * String container all the define statements that should be set on the shader.
  33104. */
  33105. defines: string;
  33106. /**
  33107. * Callback that will be called when the shader is compiled.
  33108. */
  33109. onCompiled: Nullable<(effect: Effect) => void>;
  33110. /**
  33111. * Callback that will be called if an error occurs during shader compilation.
  33112. */
  33113. onError: Nullable<(effect: Effect, errors: string) => void>;
  33114. /**
  33115. * Callback that will be called when effect is bound.
  33116. */
  33117. onBind: Nullable<(effect: Effect) => void>;
  33118. /**
  33119. * Unique ID of the effect.
  33120. */
  33121. uniqueId: number;
  33122. /**
  33123. * Observable that will be called when the shader is compiled.
  33124. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33125. */
  33126. onCompileObservable: Observable<Effect>;
  33127. /**
  33128. * Observable that will be called if an error occurs during shader compilation.
  33129. */
  33130. onErrorObservable: Observable<Effect>;
  33131. /** @hidden */
  33132. _onBindObservable: Nullable<Observable<Effect>>;
  33133. /**
  33134. * @hidden
  33135. * Specifies if the effect was previously ready
  33136. */
  33137. _wasPreviouslyReady: boolean;
  33138. /**
  33139. * Observable that will be called when effect is bound.
  33140. */
  33141. get onBindObservable(): Observable<Effect>;
  33142. /** @hidden */
  33143. _bonesComputationForcedToCPU: boolean;
  33144. private static _uniqueIdSeed;
  33145. private _engine;
  33146. private _uniformBuffersNames;
  33147. private _uniformBuffersNamesList;
  33148. private _uniformsNames;
  33149. private _samplerList;
  33150. private _samplers;
  33151. private _isReady;
  33152. private _compilationError;
  33153. private _allFallbacksProcessed;
  33154. private _attributesNames;
  33155. private _attributes;
  33156. private _attributeLocationByName;
  33157. private _uniforms;
  33158. /**
  33159. * Key for the effect.
  33160. * @hidden
  33161. */
  33162. _key: string;
  33163. private _indexParameters;
  33164. private _fallbacks;
  33165. private _vertexSourceCode;
  33166. private _fragmentSourceCode;
  33167. private _vertexSourceCodeOverride;
  33168. private _fragmentSourceCodeOverride;
  33169. private _transformFeedbackVaryings;
  33170. /**
  33171. * Compiled shader to webGL program.
  33172. * @hidden
  33173. */
  33174. _pipelineContext: Nullable<IPipelineContext>;
  33175. private _valueCache;
  33176. private static _baseCache;
  33177. /**
  33178. * Instantiates an effect.
  33179. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33180. * @param baseName Name of the effect.
  33181. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33182. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33183. * @param samplers List of sampler variables that will be passed to the shader.
  33184. * @param engine Engine to be used to render the effect
  33185. * @param defines Define statements to be added to the shader.
  33186. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33187. * @param onCompiled Callback that will be called when the shader is compiled.
  33188. * @param onError Callback that will be called if an error occurs during shader compilation.
  33189. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33190. */
  33191. 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);
  33192. private _useFinalCode;
  33193. /**
  33194. * Unique key for this effect
  33195. */
  33196. get key(): string;
  33197. /**
  33198. * If the effect has been compiled and prepared.
  33199. * @returns if the effect is compiled and prepared.
  33200. */
  33201. isReady(): boolean;
  33202. private _isReadyInternal;
  33203. /**
  33204. * The engine the effect was initialized with.
  33205. * @returns the engine.
  33206. */
  33207. getEngine(): Engine;
  33208. /**
  33209. * The pipeline context for this effect
  33210. * @returns the associated pipeline context
  33211. */
  33212. getPipelineContext(): Nullable<IPipelineContext>;
  33213. /**
  33214. * The set of names of attribute variables for the shader.
  33215. * @returns An array of attribute names.
  33216. */
  33217. getAttributesNames(): string[];
  33218. /**
  33219. * Returns the attribute at the given index.
  33220. * @param index The index of the attribute.
  33221. * @returns The location of the attribute.
  33222. */
  33223. getAttributeLocation(index: number): number;
  33224. /**
  33225. * Returns the attribute based on the name of the variable.
  33226. * @param name of the attribute to look up.
  33227. * @returns the attribute location.
  33228. */
  33229. getAttributeLocationByName(name: string): number;
  33230. /**
  33231. * The number of attributes.
  33232. * @returns the numnber of attributes.
  33233. */
  33234. getAttributesCount(): number;
  33235. /**
  33236. * Gets the index of a uniform variable.
  33237. * @param uniformName of the uniform to look up.
  33238. * @returns the index.
  33239. */
  33240. getUniformIndex(uniformName: string): number;
  33241. /**
  33242. * Returns the attribute based on the name of the variable.
  33243. * @param uniformName of the uniform to look up.
  33244. * @returns the location of the uniform.
  33245. */
  33246. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33247. /**
  33248. * Returns an array of sampler variable names
  33249. * @returns The array of sampler variable names.
  33250. */
  33251. getSamplers(): string[];
  33252. /**
  33253. * Returns an array of uniform variable names
  33254. * @returns The array of uniform variable names.
  33255. */
  33256. getUniformNames(): string[];
  33257. /**
  33258. * Returns an array of uniform buffer variable names
  33259. * @returns The array of uniform buffer variable names.
  33260. */
  33261. getUniformBuffersNames(): string[];
  33262. /**
  33263. * Returns the index parameters used to create the effect
  33264. * @returns The index parameters object
  33265. */
  33266. getIndexParameters(): any;
  33267. /**
  33268. * The error from the last compilation.
  33269. * @returns the error string.
  33270. */
  33271. getCompilationError(): string;
  33272. /**
  33273. * Gets a boolean indicating that all fallbacks were used during compilation
  33274. * @returns true if all fallbacks were used
  33275. */
  33276. allFallbacksProcessed(): boolean;
  33277. /**
  33278. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33279. * @param func The callback to be used.
  33280. */
  33281. executeWhenCompiled(func: (effect: Effect) => void): void;
  33282. private _checkIsReady;
  33283. private _loadShader;
  33284. /**
  33285. * Gets the vertex shader source code of this effect
  33286. */
  33287. get vertexSourceCode(): string;
  33288. /**
  33289. * Gets the fragment shader source code of this effect
  33290. */
  33291. get fragmentSourceCode(): string;
  33292. /**
  33293. * Recompiles the webGL program
  33294. * @param vertexSourceCode The source code for the vertex shader.
  33295. * @param fragmentSourceCode The source code for the fragment shader.
  33296. * @param onCompiled Callback called when completed.
  33297. * @param onError Callback called on error.
  33298. * @hidden
  33299. */
  33300. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33301. /**
  33302. * Prepares the effect
  33303. * @hidden
  33304. */
  33305. _prepareEffect(): void;
  33306. private _getShaderCodeAndErrorLine;
  33307. private _processCompilationErrors;
  33308. /**
  33309. * Checks if the effect is supported. (Must be called after compilation)
  33310. */
  33311. get isSupported(): boolean;
  33312. /**
  33313. * Binds a texture to the engine to be used as output of the shader.
  33314. * @param channel Name of the output variable.
  33315. * @param texture Texture to bind.
  33316. * @hidden
  33317. */
  33318. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33319. /**
  33320. * Sets a texture on the engine to be used in the shader.
  33321. * @param channel Name of the sampler variable.
  33322. * @param texture Texture to set.
  33323. */
  33324. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33325. /**
  33326. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33327. * @param channel Name of the sampler variable.
  33328. * @param texture Texture to set.
  33329. */
  33330. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33331. /**
  33332. * Sets an array of textures on the engine to be used in the shader.
  33333. * @param channel Name of the variable.
  33334. * @param textures Textures to set.
  33335. */
  33336. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33337. /**
  33338. * 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)
  33339. * @param channel Name of the sampler variable.
  33340. * @param postProcess Post process to get the input texture from.
  33341. */
  33342. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33343. /**
  33344. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33345. * 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)
  33346. * @param channel Name of the sampler variable.
  33347. * @param postProcess Post process to get the output texture from.
  33348. */
  33349. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33350. /** @hidden */
  33351. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33352. /** @hidden */
  33353. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33354. /** @hidden */
  33355. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33356. /** @hidden */
  33357. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33358. /**
  33359. * Binds a buffer to a uniform.
  33360. * @param buffer Buffer to bind.
  33361. * @param name Name of the uniform variable to bind to.
  33362. */
  33363. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33364. /**
  33365. * Binds block to a uniform.
  33366. * @param blockName Name of the block to bind.
  33367. * @param index Index to bind.
  33368. */
  33369. bindUniformBlock(blockName: string, index: number): void;
  33370. /**
  33371. * Sets an interger value on a uniform variable.
  33372. * @param uniformName Name of the variable.
  33373. * @param value Value to be set.
  33374. * @returns this effect.
  33375. */
  33376. setInt(uniformName: string, value: number): Effect;
  33377. /**
  33378. * Sets an int array on a uniform variable.
  33379. * @param uniformName Name of the variable.
  33380. * @param array array to be set.
  33381. * @returns this effect.
  33382. */
  33383. setIntArray(uniformName: string, array: Int32Array): Effect;
  33384. /**
  33385. * 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)
  33386. * @param uniformName Name of the variable.
  33387. * @param array array to be set.
  33388. * @returns this effect.
  33389. */
  33390. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33391. /**
  33392. * 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)
  33393. * @param uniformName Name of the variable.
  33394. * @param array array to be set.
  33395. * @returns this effect.
  33396. */
  33397. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33398. /**
  33399. * 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)
  33400. * @param uniformName Name of the variable.
  33401. * @param array array to be set.
  33402. * @returns this effect.
  33403. */
  33404. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33405. /**
  33406. * Sets an float array on a uniform variable.
  33407. * @param uniformName Name of the variable.
  33408. * @param array array to be set.
  33409. * @returns this effect.
  33410. */
  33411. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33412. /**
  33413. * 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)
  33414. * @param uniformName Name of the variable.
  33415. * @param array array to be set.
  33416. * @returns this effect.
  33417. */
  33418. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33419. /**
  33420. * 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)
  33421. * @param uniformName Name of the variable.
  33422. * @param array array to be set.
  33423. * @returns this effect.
  33424. */
  33425. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33426. /**
  33427. * 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)
  33428. * @param uniformName Name of the variable.
  33429. * @param array array to be set.
  33430. * @returns this effect.
  33431. */
  33432. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33433. /**
  33434. * Sets an array on a uniform variable.
  33435. * @param uniformName Name of the variable.
  33436. * @param array array to be set.
  33437. * @returns this effect.
  33438. */
  33439. setArray(uniformName: string, array: number[]): Effect;
  33440. /**
  33441. * 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)
  33442. * @param uniformName Name of the variable.
  33443. * @param array array to be set.
  33444. * @returns this effect.
  33445. */
  33446. setArray2(uniformName: string, array: number[]): Effect;
  33447. /**
  33448. * 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)
  33449. * @param uniformName Name of the variable.
  33450. * @param array array to be set.
  33451. * @returns this effect.
  33452. */
  33453. setArray3(uniformName: string, array: number[]): Effect;
  33454. /**
  33455. * 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)
  33456. * @param uniformName Name of the variable.
  33457. * @param array array to be set.
  33458. * @returns this effect.
  33459. */
  33460. setArray4(uniformName: string, array: number[]): Effect;
  33461. /**
  33462. * Sets matrices on a uniform variable.
  33463. * @param uniformName Name of the variable.
  33464. * @param matrices matrices to be set.
  33465. * @returns this effect.
  33466. */
  33467. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33468. /**
  33469. * Sets matrix on a uniform variable.
  33470. * @param uniformName Name of the variable.
  33471. * @param matrix matrix to be set.
  33472. * @returns this effect.
  33473. */
  33474. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33475. /**
  33476. * 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)
  33477. * @param uniformName Name of the variable.
  33478. * @param matrix matrix to be set.
  33479. * @returns this effect.
  33480. */
  33481. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33482. /**
  33483. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33484. * @param uniformName Name of the variable.
  33485. * @param matrix matrix to be set.
  33486. * @returns this effect.
  33487. */
  33488. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33489. /**
  33490. * Sets a float on a uniform variable.
  33491. * @param uniformName Name of the variable.
  33492. * @param value value to be set.
  33493. * @returns this effect.
  33494. */
  33495. setFloat(uniformName: string, value: number): Effect;
  33496. /**
  33497. * Sets a boolean on a uniform variable.
  33498. * @param uniformName Name of the variable.
  33499. * @param bool value to be set.
  33500. * @returns this effect.
  33501. */
  33502. setBool(uniformName: string, bool: boolean): Effect;
  33503. /**
  33504. * Sets a Vector2 on a uniform variable.
  33505. * @param uniformName Name of the variable.
  33506. * @param vector2 vector2 to be set.
  33507. * @returns this effect.
  33508. */
  33509. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33510. /**
  33511. * Sets a float2 on a uniform variable.
  33512. * @param uniformName Name of the variable.
  33513. * @param x First float in float2.
  33514. * @param y Second float in float2.
  33515. * @returns this effect.
  33516. */
  33517. setFloat2(uniformName: string, x: number, y: number): Effect;
  33518. /**
  33519. * Sets a Vector3 on a uniform variable.
  33520. * @param uniformName Name of the variable.
  33521. * @param vector3 Value to be set.
  33522. * @returns this effect.
  33523. */
  33524. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33525. /**
  33526. * Sets a float3 on a uniform variable.
  33527. * @param uniformName Name of the variable.
  33528. * @param x First float in float3.
  33529. * @param y Second float in float3.
  33530. * @param z Third float in float3.
  33531. * @returns this effect.
  33532. */
  33533. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33534. /**
  33535. * Sets a Vector4 on a uniform variable.
  33536. * @param uniformName Name of the variable.
  33537. * @param vector4 Value to be set.
  33538. * @returns this effect.
  33539. */
  33540. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33541. /**
  33542. * Sets a float4 on a uniform variable.
  33543. * @param uniformName Name of the variable.
  33544. * @param x First float in float4.
  33545. * @param y Second float in float4.
  33546. * @param z Third float in float4.
  33547. * @param w Fourth float in float4.
  33548. * @returns this effect.
  33549. */
  33550. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33551. /**
  33552. * Sets a Color3 on a uniform variable.
  33553. * @param uniformName Name of the variable.
  33554. * @param color3 Value to be set.
  33555. * @returns this effect.
  33556. */
  33557. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33558. /**
  33559. * Sets a Color4 on a uniform variable.
  33560. * @param uniformName Name of the variable.
  33561. * @param color3 Value to be set.
  33562. * @param alpha Alpha value to be set.
  33563. * @returns this effect.
  33564. */
  33565. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33566. /**
  33567. * Sets a Color4 on a uniform variable
  33568. * @param uniformName defines the name of the variable
  33569. * @param color4 defines the value to be set
  33570. * @returns this effect.
  33571. */
  33572. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33573. /** Release all associated resources */
  33574. dispose(): void;
  33575. /**
  33576. * This function will add a new shader to the shader store
  33577. * @param name the name of the shader
  33578. * @param pixelShader optional pixel shader content
  33579. * @param vertexShader optional vertex shader content
  33580. */
  33581. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33582. /**
  33583. * Store of each shader (The can be looked up using effect.key)
  33584. */
  33585. static ShadersStore: {
  33586. [key: string]: string;
  33587. };
  33588. /**
  33589. * Store of each included file for a shader (The can be looked up using effect.key)
  33590. */
  33591. static IncludesShadersStore: {
  33592. [key: string]: string;
  33593. };
  33594. /**
  33595. * Resets the cache of effects.
  33596. */
  33597. static ResetCache(): void;
  33598. }
  33599. }
  33600. declare module BABYLON {
  33601. /**
  33602. * Interface used to describe the capabilities of the engine relatively to the current browser
  33603. */
  33604. export interface EngineCapabilities {
  33605. /** Maximum textures units per fragment shader */
  33606. maxTexturesImageUnits: number;
  33607. /** Maximum texture units per vertex shader */
  33608. maxVertexTextureImageUnits: number;
  33609. /** Maximum textures units in the entire pipeline */
  33610. maxCombinedTexturesImageUnits: number;
  33611. /** Maximum texture size */
  33612. maxTextureSize: number;
  33613. /** Maximum texture samples */
  33614. maxSamples?: number;
  33615. /** Maximum cube texture size */
  33616. maxCubemapTextureSize: number;
  33617. /** Maximum render texture size */
  33618. maxRenderTextureSize: number;
  33619. /** Maximum number of vertex attributes */
  33620. maxVertexAttribs: number;
  33621. /** Maximum number of varyings */
  33622. maxVaryingVectors: number;
  33623. /** Maximum number of uniforms per vertex shader */
  33624. maxVertexUniformVectors: number;
  33625. /** Maximum number of uniforms per fragment shader */
  33626. maxFragmentUniformVectors: number;
  33627. /** Defines if standard derivates (dx/dy) are supported */
  33628. standardDerivatives: boolean;
  33629. /** Defines if s3tc texture compression is supported */
  33630. s3tc?: WEBGL_compressed_texture_s3tc;
  33631. /** Defines if pvrtc texture compression is supported */
  33632. pvrtc: any;
  33633. /** Defines if etc1 texture compression is supported */
  33634. etc1: any;
  33635. /** Defines if etc2 texture compression is supported */
  33636. etc2: any;
  33637. /** Defines if astc texture compression is supported */
  33638. astc: any;
  33639. /** Defines if float textures are supported */
  33640. textureFloat: boolean;
  33641. /** Defines if vertex array objects are supported */
  33642. vertexArrayObject: boolean;
  33643. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33644. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33645. /** Gets the maximum level of anisotropy supported */
  33646. maxAnisotropy: number;
  33647. /** Defines if instancing is supported */
  33648. instancedArrays: boolean;
  33649. /** Defines if 32 bits indices are supported */
  33650. uintIndices: boolean;
  33651. /** Defines if high precision shaders are supported */
  33652. highPrecisionShaderSupported: boolean;
  33653. /** Defines if depth reading in the fragment shader is supported */
  33654. fragmentDepthSupported: boolean;
  33655. /** Defines if float texture linear filtering is supported*/
  33656. textureFloatLinearFiltering: boolean;
  33657. /** Defines if rendering to float textures is supported */
  33658. textureFloatRender: boolean;
  33659. /** Defines if half float textures are supported*/
  33660. textureHalfFloat: boolean;
  33661. /** Defines if half float texture linear filtering is supported*/
  33662. textureHalfFloatLinearFiltering: boolean;
  33663. /** Defines if rendering to half float textures is supported */
  33664. textureHalfFloatRender: boolean;
  33665. /** Defines if textureLOD shader command is supported */
  33666. textureLOD: boolean;
  33667. /** Defines if draw buffers extension is supported */
  33668. drawBuffersExtension: boolean;
  33669. /** Defines if depth textures are supported */
  33670. depthTextureExtension: boolean;
  33671. /** Defines if float color buffer are supported */
  33672. colorBufferFloat: boolean;
  33673. /** Gets disjoint timer query extension (null if not supported) */
  33674. timerQuery?: EXT_disjoint_timer_query;
  33675. /** Defines if timestamp can be used with timer query */
  33676. canUseTimestampForTimerQuery: boolean;
  33677. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33678. multiview?: any;
  33679. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33680. oculusMultiview?: any;
  33681. /** Function used to let the system compiles shaders in background */
  33682. parallelShaderCompile?: {
  33683. COMPLETION_STATUS_KHR: number;
  33684. };
  33685. /** Max number of texture samples for MSAA */
  33686. maxMSAASamples: number;
  33687. /** Defines if the blend min max extension is supported */
  33688. blendMinMax: boolean;
  33689. }
  33690. }
  33691. declare module BABYLON {
  33692. /**
  33693. * @hidden
  33694. **/
  33695. export class DepthCullingState {
  33696. private _isDepthTestDirty;
  33697. private _isDepthMaskDirty;
  33698. private _isDepthFuncDirty;
  33699. private _isCullFaceDirty;
  33700. private _isCullDirty;
  33701. private _isZOffsetDirty;
  33702. private _isFrontFaceDirty;
  33703. private _depthTest;
  33704. private _depthMask;
  33705. private _depthFunc;
  33706. private _cull;
  33707. private _cullFace;
  33708. private _zOffset;
  33709. private _frontFace;
  33710. /**
  33711. * Initializes the state.
  33712. */
  33713. constructor();
  33714. get isDirty(): boolean;
  33715. get zOffset(): number;
  33716. set zOffset(value: number);
  33717. get cullFace(): Nullable<number>;
  33718. set cullFace(value: Nullable<number>);
  33719. get cull(): Nullable<boolean>;
  33720. set cull(value: Nullable<boolean>);
  33721. get depthFunc(): Nullable<number>;
  33722. set depthFunc(value: Nullable<number>);
  33723. get depthMask(): boolean;
  33724. set depthMask(value: boolean);
  33725. get depthTest(): boolean;
  33726. set depthTest(value: boolean);
  33727. get frontFace(): Nullable<number>;
  33728. set frontFace(value: Nullable<number>);
  33729. reset(): void;
  33730. apply(gl: WebGLRenderingContext): void;
  33731. }
  33732. }
  33733. declare module BABYLON {
  33734. /**
  33735. * @hidden
  33736. **/
  33737. export class StencilState {
  33738. /** 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 */
  33739. static readonly ALWAYS: number;
  33740. /** Passed to stencilOperation to specify that stencil value must be kept */
  33741. static readonly KEEP: number;
  33742. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33743. static readonly REPLACE: number;
  33744. private _isStencilTestDirty;
  33745. private _isStencilMaskDirty;
  33746. private _isStencilFuncDirty;
  33747. private _isStencilOpDirty;
  33748. private _stencilTest;
  33749. private _stencilMask;
  33750. private _stencilFunc;
  33751. private _stencilFuncRef;
  33752. private _stencilFuncMask;
  33753. private _stencilOpStencilFail;
  33754. private _stencilOpDepthFail;
  33755. private _stencilOpStencilDepthPass;
  33756. get isDirty(): boolean;
  33757. get stencilFunc(): number;
  33758. set stencilFunc(value: number);
  33759. get stencilFuncRef(): number;
  33760. set stencilFuncRef(value: number);
  33761. get stencilFuncMask(): number;
  33762. set stencilFuncMask(value: number);
  33763. get stencilOpStencilFail(): number;
  33764. set stencilOpStencilFail(value: number);
  33765. get stencilOpDepthFail(): number;
  33766. set stencilOpDepthFail(value: number);
  33767. get stencilOpStencilDepthPass(): number;
  33768. set stencilOpStencilDepthPass(value: number);
  33769. get stencilMask(): number;
  33770. set stencilMask(value: number);
  33771. get stencilTest(): boolean;
  33772. set stencilTest(value: boolean);
  33773. constructor();
  33774. reset(): void;
  33775. apply(gl: WebGLRenderingContext): void;
  33776. }
  33777. }
  33778. declare module BABYLON {
  33779. /**
  33780. * @hidden
  33781. **/
  33782. export class AlphaState {
  33783. private _isAlphaBlendDirty;
  33784. private _isBlendFunctionParametersDirty;
  33785. private _isBlendEquationParametersDirty;
  33786. private _isBlendConstantsDirty;
  33787. private _alphaBlend;
  33788. private _blendFunctionParameters;
  33789. private _blendEquationParameters;
  33790. private _blendConstants;
  33791. /**
  33792. * Initializes the state.
  33793. */
  33794. constructor();
  33795. get isDirty(): boolean;
  33796. get alphaBlend(): boolean;
  33797. set alphaBlend(value: boolean);
  33798. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  33799. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33800. setAlphaEquationParameters(rgb: number, alpha: number): void;
  33801. reset(): void;
  33802. apply(gl: WebGLRenderingContext): void;
  33803. }
  33804. }
  33805. declare module BABYLON {
  33806. /** @hidden */
  33807. export class WebGL2ShaderProcessor implements IShaderProcessor {
  33808. attributeProcessor(attribute: string): string;
  33809. varyingProcessor(varying: string, isFragment: boolean): string;
  33810. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  33811. }
  33812. }
  33813. declare module BABYLON {
  33814. /**
  33815. * Interface for attribute information associated with buffer instanciation
  33816. */
  33817. export interface InstancingAttributeInfo {
  33818. /**
  33819. * Name of the GLSL attribute
  33820. * if attribute index is not specified, this is used to retrieve the index from the effect
  33821. */
  33822. attributeName: string;
  33823. /**
  33824. * Index/offset of the attribute in the vertex shader
  33825. * if not specified, this will be computes from the name.
  33826. */
  33827. index?: number;
  33828. /**
  33829. * size of the attribute, 1, 2, 3 or 4
  33830. */
  33831. attributeSize: number;
  33832. /**
  33833. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  33834. */
  33835. offset: number;
  33836. /**
  33837. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  33838. * default to 1
  33839. */
  33840. divisor?: number;
  33841. /**
  33842. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  33843. * default is FLOAT
  33844. */
  33845. attributeType?: number;
  33846. /**
  33847. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  33848. */
  33849. normalized?: boolean;
  33850. }
  33851. }
  33852. declare module BABYLON {
  33853. interface ThinEngine {
  33854. /**
  33855. * Update a video texture
  33856. * @param texture defines the texture to update
  33857. * @param video defines the video element to use
  33858. * @param invertY defines if data must be stored with Y axis inverted
  33859. */
  33860. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  33861. }
  33862. }
  33863. declare module BABYLON {
  33864. /**
  33865. * Settings for finer control over video usage
  33866. */
  33867. export interface VideoTextureSettings {
  33868. /**
  33869. * Applies `autoplay` to video, if specified
  33870. */
  33871. autoPlay?: boolean;
  33872. /**
  33873. * Applies `loop` to video, if specified
  33874. */
  33875. loop?: boolean;
  33876. /**
  33877. * Automatically updates internal texture from video at every frame in the render loop
  33878. */
  33879. autoUpdateTexture: boolean;
  33880. /**
  33881. * Image src displayed during the video loading or until the user interacts with the video.
  33882. */
  33883. poster?: string;
  33884. }
  33885. /**
  33886. * If you want to display a video in your scene, this is the special texture for that.
  33887. * This special texture works similar to other textures, with the exception of a few parameters.
  33888. * @see https://doc.babylonjs.com/how_to/video_texture
  33889. */
  33890. export class VideoTexture extends Texture {
  33891. /**
  33892. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  33893. */
  33894. readonly autoUpdateTexture: boolean;
  33895. /**
  33896. * The video instance used by the texture internally
  33897. */
  33898. readonly video: HTMLVideoElement;
  33899. private _onUserActionRequestedObservable;
  33900. /**
  33901. * Event triggerd when a dom action is required by the user to play the video.
  33902. * This happens due to recent changes in browser policies preventing video to auto start.
  33903. */
  33904. get onUserActionRequestedObservable(): Observable<Texture>;
  33905. private _generateMipMaps;
  33906. private _stillImageCaptured;
  33907. private _displayingPosterTexture;
  33908. private _settings;
  33909. private _createInternalTextureOnEvent;
  33910. private _frameId;
  33911. private _currentSrc;
  33912. /**
  33913. * Creates a video texture.
  33914. * If you want to display a video in your scene, this is the special texture for that.
  33915. * This special texture works similar to other textures, with the exception of a few parameters.
  33916. * @see https://doc.babylonjs.com/how_to/video_texture
  33917. * @param name optional name, will detect from video source, if not defined
  33918. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  33919. * @param scene is obviously the current scene.
  33920. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  33921. * @param invertY is false by default but can be used to invert video on Y axis
  33922. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  33923. * @param settings allows finer control over video usage
  33924. */
  33925. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  33926. private _getName;
  33927. private _getVideo;
  33928. private _createInternalTexture;
  33929. private reset;
  33930. /**
  33931. * @hidden Internal method to initiate `update`.
  33932. */
  33933. _rebuild(): void;
  33934. /**
  33935. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  33936. */
  33937. update(): void;
  33938. /**
  33939. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  33940. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  33941. */
  33942. updateTexture(isVisible: boolean): void;
  33943. protected _updateInternalTexture: () => void;
  33944. /**
  33945. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  33946. * @param url New url.
  33947. */
  33948. updateURL(url: string): void;
  33949. /**
  33950. * Clones the texture.
  33951. * @returns the cloned texture
  33952. */
  33953. clone(): VideoTexture;
  33954. /**
  33955. * Dispose the texture and release its associated resources.
  33956. */
  33957. dispose(): void;
  33958. /**
  33959. * Creates a video texture straight from a stream.
  33960. * @param scene Define the scene the texture should be created in
  33961. * @param stream Define the stream the texture should be created from
  33962. * @returns The created video texture as a promise
  33963. */
  33964. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  33965. /**
  33966. * Creates a video texture straight from your WebCam video feed.
  33967. * @param scene Define the scene the texture should be created in
  33968. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33969. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33970. * @returns The created video texture as a promise
  33971. */
  33972. static CreateFromWebCamAsync(scene: Scene, constraints: {
  33973. minWidth: number;
  33974. maxWidth: number;
  33975. minHeight: number;
  33976. maxHeight: number;
  33977. deviceId: string;
  33978. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  33979. /**
  33980. * Creates a video texture straight from your WebCam video feed.
  33981. * @param scene Define the scene the texture should be created in
  33982. * @param onReady Define a callback to triggered once the texture will be ready
  33983. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  33984. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  33985. */
  33986. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  33987. minWidth: number;
  33988. maxWidth: number;
  33989. minHeight: number;
  33990. maxHeight: number;
  33991. deviceId: string;
  33992. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  33993. }
  33994. }
  33995. declare module BABYLON {
  33996. /**
  33997. * Defines the interface used by objects working like Scene
  33998. * @hidden
  33999. */
  34000. export interface ISceneLike {
  34001. _addPendingData(data: any): void;
  34002. _removePendingData(data: any): void;
  34003. offlineProvider: IOfflineProvider;
  34004. }
  34005. /** Interface defining initialization parameters for Engine class */
  34006. export interface EngineOptions extends WebGLContextAttributes {
  34007. /**
  34008. * Defines if the engine should no exceed a specified device ratio
  34009. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34010. */
  34011. limitDeviceRatio?: number;
  34012. /**
  34013. * Defines if webvr should be enabled automatically
  34014. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34015. */
  34016. autoEnableWebVR?: boolean;
  34017. /**
  34018. * Defines if webgl2 should be turned off even if supported
  34019. * @see http://doc.babylonjs.com/features/webgl2
  34020. */
  34021. disableWebGL2Support?: boolean;
  34022. /**
  34023. * Defines if webaudio should be initialized as well
  34024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34025. */
  34026. audioEngine?: boolean;
  34027. /**
  34028. * Defines if animations should run using a deterministic lock step
  34029. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34030. */
  34031. deterministicLockstep?: boolean;
  34032. /** Defines the maximum steps to use with deterministic lock step mode */
  34033. lockstepMaxSteps?: number;
  34034. /** Defines the seconds between each deterministic lock step */
  34035. timeStep?: number;
  34036. /**
  34037. * Defines that engine should ignore context lost events
  34038. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34039. */
  34040. doNotHandleContextLost?: boolean;
  34041. /**
  34042. * Defines that engine should ignore modifying touch action attribute and style
  34043. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34044. */
  34045. doNotHandleTouchAction?: boolean;
  34046. /**
  34047. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34048. */
  34049. useHighPrecisionFloats?: boolean;
  34050. }
  34051. /**
  34052. * The base engine class (root of all engines)
  34053. */
  34054. export class ThinEngine {
  34055. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34056. static ExceptionList: ({
  34057. key: string;
  34058. capture: string;
  34059. captureConstraint: number;
  34060. targets: string[];
  34061. } | {
  34062. key: string;
  34063. capture: null;
  34064. captureConstraint: null;
  34065. targets: string[];
  34066. })[];
  34067. /** @hidden */
  34068. static _TextureLoaders: IInternalTextureLoader[];
  34069. /**
  34070. * Returns the current npm package of the sdk
  34071. */
  34072. static get NpmPackage(): string;
  34073. /**
  34074. * Returns the current version of the framework
  34075. */
  34076. static get Version(): string;
  34077. /**
  34078. * Returns a string describing the current engine
  34079. */
  34080. get description(): string;
  34081. /**
  34082. * Gets or sets the epsilon value used by collision engine
  34083. */
  34084. static CollisionsEpsilon: number;
  34085. /**
  34086. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34087. */
  34088. static get ShadersRepository(): string;
  34089. static set ShadersRepository(value: string);
  34090. /** @hidden */
  34091. _shaderProcessor: IShaderProcessor;
  34092. /**
  34093. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34094. */
  34095. forcePOTTextures: boolean;
  34096. /**
  34097. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34098. */
  34099. isFullscreen: boolean;
  34100. /**
  34101. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34102. */
  34103. cullBackFaces: boolean;
  34104. /**
  34105. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34106. */
  34107. renderEvenInBackground: boolean;
  34108. /**
  34109. * Gets or sets a boolean indicating that cache can be kept between frames
  34110. */
  34111. preventCacheWipeBetweenFrames: boolean;
  34112. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34113. validateShaderPrograms: boolean;
  34114. /**
  34115. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34116. * This can provide greater z depth for distant objects.
  34117. */
  34118. useReverseDepthBuffer: boolean;
  34119. /**
  34120. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34121. */
  34122. disableUniformBuffers: boolean;
  34123. /** @hidden */
  34124. _uniformBuffers: UniformBuffer[];
  34125. /**
  34126. * Gets a boolean indicating that the engine supports uniform buffers
  34127. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34128. */
  34129. get supportsUniformBuffers(): boolean;
  34130. /** @hidden */
  34131. _gl: WebGLRenderingContext;
  34132. /** @hidden */
  34133. _webGLVersion: number;
  34134. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34135. protected _windowIsBackground: boolean;
  34136. protected _creationOptions: EngineOptions;
  34137. protected _highPrecisionShadersAllowed: boolean;
  34138. /** @hidden */
  34139. get _shouldUseHighPrecisionShader(): boolean;
  34140. /**
  34141. * Gets a boolean indicating that only power of 2 textures are supported
  34142. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34143. */
  34144. get needPOTTextures(): boolean;
  34145. /** @hidden */
  34146. _badOS: boolean;
  34147. /** @hidden */
  34148. _badDesktopOS: boolean;
  34149. private _hardwareScalingLevel;
  34150. /** @hidden */
  34151. _caps: EngineCapabilities;
  34152. private _isStencilEnable;
  34153. private _glVersion;
  34154. private _glRenderer;
  34155. private _glVendor;
  34156. /** @hidden */
  34157. _videoTextureSupported: boolean;
  34158. protected _renderingQueueLaunched: boolean;
  34159. protected _activeRenderLoops: (() => void)[];
  34160. /**
  34161. * Observable signaled when a context lost event is raised
  34162. */
  34163. onContextLostObservable: Observable<ThinEngine>;
  34164. /**
  34165. * Observable signaled when a context restored event is raised
  34166. */
  34167. onContextRestoredObservable: Observable<ThinEngine>;
  34168. private _onContextLost;
  34169. private _onContextRestored;
  34170. protected _contextWasLost: boolean;
  34171. /** @hidden */
  34172. _doNotHandleContextLost: boolean;
  34173. /**
  34174. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34175. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34176. */
  34177. get doNotHandleContextLost(): boolean;
  34178. set doNotHandleContextLost(value: boolean);
  34179. /**
  34180. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34181. */
  34182. disableVertexArrayObjects: boolean;
  34183. /** @hidden */
  34184. protected _colorWrite: boolean;
  34185. /** @hidden */
  34186. protected _colorWriteChanged: boolean;
  34187. /** @hidden */
  34188. protected _depthCullingState: DepthCullingState;
  34189. /** @hidden */
  34190. protected _stencilState: StencilState;
  34191. /** @hidden */
  34192. _alphaState: AlphaState;
  34193. /** @hidden */
  34194. _alphaMode: number;
  34195. /** @hidden */
  34196. _alphaEquation: number;
  34197. /** @hidden */
  34198. _internalTexturesCache: InternalTexture[];
  34199. /** @hidden */
  34200. protected _activeChannel: number;
  34201. private _currentTextureChannel;
  34202. /** @hidden */
  34203. protected _boundTexturesCache: {
  34204. [key: string]: Nullable<InternalTexture>;
  34205. };
  34206. /** @hidden */
  34207. protected _currentEffect: Nullable<Effect>;
  34208. /** @hidden */
  34209. protected _currentProgram: Nullable<WebGLProgram>;
  34210. private _compiledEffects;
  34211. private _vertexAttribArraysEnabled;
  34212. /** @hidden */
  34213. protected _cachedViewport: Nullable<IViewportLike>;
  34214. private _cachedVertexArrayObject;
  34215. /** @hidden */
  34216. protected _cachedVertexBuffers: any;
  34217. /** @hidden */
  34218. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34219. /** @hidden */
  34220. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34221. /** @hidden */
  34222. _currentRenderTarget: Nullable<InternalTexture>;
  34223. private _uintIndicesCurrentlySet;
  34224. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34225. /** @hidden */
  34226. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34227. /** @hidden */
  34228. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34229. private _currentBufferPointers;
  34230. private _currentInstanceLocations;
  34231. private _currentInstanceBuffers;
  34232. private _textureUnits;
  34233. /** @hidden */
  34234. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34235. /** @hidden */
  34236. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34237. /** @hidden */
  34238. _boundRenderFunction: any;
  34239. private _vaoRecordInProgress;
  34240. private _mustWipeVertexAttributes;
  34241. private _emptyTexture;
  34242. private _emptyCubeTexture;
  34243. private _emptyTexture3D;
  34244. private _emptyTexture2DArray;
  34245. /** @hidden */
  34246. _frameHandler: number;
  34247. private _nextFreeTextureSlots;
  34248. private _maxSimultaneousTextures;
  34249. private _activeRequests;
  34250. /** @hidden */
  34251. _transformTextureUrl: Nullable<(url: string) => string>;
  34252. protected get _supportsHardwareTextureRescaling(): boolean;
  34253. private _framebufferDimensionsObject;
  34254. /**
  34255. * sets the object from which width and height will be taken from when getting render width and height
  34256. * Will fallback to the gl object
  34257. * @param dimensions the framebuffer width and height that will be used.
  34258. */
  34259. set framebufferDimensionsObject(dimensions: Nullable<{
  34260. framebufferWidth: number;
  34261. framebufferHeight: number;
  34262. }>);
  34263. /**
  34264. * Gets the current viewport
  34265. */
  34266. get currentViewport(): Nullable<IViewportLike>;
  34267. /**
  34268. * Gets the default empty texture
  34269. */
  34270. get emptyTexture(): InternalTexture;
  34271. /**
  34272. * Gets the default empty 3D texture
  34273. */
  34274. get emptyTexture3D(): InternalTexture;
  34275. /**
  34276. * Gets the default empty 2D array texture
  34277. */
  34278. get emptyTexture2DArray(): InternalTexture;
  34279. /**
  34280. * Gets the default empty cube texture
  34281. */
  34282. get emptyCubeTexture(): InternalTexture;
  34283. /**
  34284. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34285. */
  34286. readonly premultipliedAlpha: boolean;
  34287. /**
  34288. * Observable event triggered before each texture is initialized
  34289. */
  34290. onBeforeTextureInitObservable: Observable<Texture>;
  34291. /**
  34292. * Creates a new engine
  34293. * @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
  34294. * @param antialias defines enable antialiasing (default: false)
  34295. * @param options defines further options to be sent to the getContext() function
  34296. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34297. */
  34298. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34299. private _rebuildInternalTextures;
  34300. private _rebuildEffects;
  34301. /**
  34302. * Gets a boolean indicating if all created effects are ready
  34303. * @returns true if all effects are ready
  34304. */
  34305. areAllEffectsReady(): boolean;
  34306. protected _rebuildBuffers(): void;
  34307. protected _initGLContext(): void;
  34308. /**
  34309. * Gets version of the current webGL context
  34310. */
  34311. get webGLVersion(): number;
  34312. /**
  34313. * Gets a string idenfifying the name of the class
  34314. * @returns "Engine" string
  34315. */
  34316. getClassName(): string;
  34317. /**
  34318. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34319. */
  34320. get isStencilEnable(): boolean;
  34321. /** @hidden */
  34322. _prepareWorkingCanvas(): void;
  34323. /**
  34324. * Reset the texture cache to empty state
  34325. */
  34326. resetTextureCache(): void;
  34327. /**
  34328. * Gets an object containing information about the current webGL context
  34329. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34330. */
  34331. getGlInfo(): {
  34332. vendor: string;
  34333. renderer: string;
  34334. version: string;
  34335. };
  34336. /**
  34337. * Defines the hardware scaling level.
  34338. * By default the hardware scaling level is computed from the window device ratio.
  34339. * 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.
  34340. * @param level defines the level to use
  34341. */
  34342. setHardwareScalingLevel(level: number): void;
  34343. /**
  34344. * Gets the current hardware scaling level.
  34345. * By default the hardware scaling level is computed from the window device ratio.
  34346. * 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.
  34347. * @returns a number indicating the current hardware scaling level
  34348. */
  34349. getHardwareScalingLevel(): number;
  34350. /**
  34351. * Gets the list of loaded textures
  34352. * @returns an array containing all loaded textures
  34353. */
  34354. getLoadedTexturesCache(): InternalTexture[];
  34355. /**
  34356. * Gets the object containing all engine capabilities
  34357. * @returns the EngineCapabilities object
  34358. */
  34359. getCaps(): EngineCapabilities;
  34360. /**
  34361. * stop executing a render loop function and remove it from the execution array
  34362. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34363. */
  34364. stopRenderLoop(renderFunction?: () => void): void;
  34365. /** @hidden */
  34366. _renderLoop(): void;
  34367. /**
  34368. * Gets the HTML canvas attached with the current webGL context
  34369. * @returns a HTML canvas
  34370. */
  34371. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34372. /**
  34373. * Gets host window
  34374. * @returns the host window object
  34375. */
  34376. getHostWindow(): Nullable<Window>;
  34377. /**
  34378. * Gets the current render width
  34379. * @param useScreen defines if screen size must be used (or the current render target if any)
  34380. * @returns a number defining the current render width
  34381. */
  34382. getRenderWidth(useScreen?: boolean): number;
  34383. /**
  34384. * Gets the current render height
  34385. * @param useScreen defines if screen size must be used (or the current render target if any)
  34386. * @returns a number defining the current render height
  34387. */
  34388. getRenderHeight(useScreen?: boolean): number;
  34389. /**
  34390. * Can be used to override the current requestAnimationFrame requester.
  34391. * @hidden
  34392. */
  34393. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34394. /**
  34395. * Register and execute a render loop. The engine can have more than one render function
  34396. * @param renderFunction defines the function to continuously execute
  34397. */
  34398. runRenderLoop(renderFunction: () => void): void;
  34399. /**
  34400. * Clear the current render buffer or the current render target (if any is set up)
  34401. * @param color defines the color to use
  34402. * @param backBuffer defines if the back buffer must be cleared
  34403. * @param depth defines if the depth buffer must be cleared
  34404. * @param stencil defines if the stencil buffer must be cleared
  34405. */
  34406. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34407. private _viewportCached;
  34408. /** @hidden */
  34409. _viewport(x: number, y: number, width: number, height: number): void;
  34410. /**
  34411. * Set the WebGL's viewport
  34412. * @param viewport defines the viewport element to be used
  34413. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34414. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34415. */
  34416. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34417. /**
  34418. * Begin a new frame
  34419. */
  34420. beginFrame(): void;
  34421. /**
  34422. * Enf the current frame
  34423. */
  34424. endFrame(): void;
  34425. /**
  34426. * Resize the view according to the canvas' size
  34427. */
  34428. resize(): void;
  34429. /**
  34430. * Force a specific size of the canvas
  34431. * @param width defines the new canvas' width
  34432. * @param height defines the new canvas' height
  34433. */
  34434. setSize(width: number, height: number): void;
  34435. /**
  34436. * Binds the frame buffer to the specified texture.
  34437. * @param texture The texture to render to or null for the default canvas
  34438. * @param faceIndex The face of the texture to render to in case of cube texture
  34439. * @param requiredWidth The width of the target to render to
  34440. * @param requiredHeight The height of the target to render to
  34441. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34442. * @param lodLevel defines the lod level to bind to the frame buffer
  34443. * @param layer defines the 2d array index to bind to frame buffer to
  34444. */
  34445. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34446. /** @hidden */
  34447. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34448. /**
  34449. * Unbind the current render target texture from the webGL context
  34450. * @param texture defines the render target texture to unbind
  34451. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34452. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34453. */
  34454. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34455. /**
  34456. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34457. */
  34458. flushFramebuffer(): void;
  34459. /**
  34460. * Unbind the current render target and bind the default framebuffer
  34461. */
  34462. restoreDefaultFramebuffer(): void;
  34463. /** @hidden */
  34464. protected _resetVertexBufferBinding(): void;
  34465. /**
  34466. * Creates a vertex buffer
  34467. * @param data the data for the vertex buffer
  34468. * @returns the new WebGL static buffer
  34469. */
  34470. createVertexBuffer(data: DataArray): DataBuffer;
  34471. private _createVertexBuffer;
  34472. /**
  34473. * Creates a dynamic vertex buffer
  34474. * @param data the data for the dynamic vertex buffer
  34475. * @returns the new WebGL dynamic buffer
  34476. */
  34477. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34478. protected _resetIndexBufferBinding(): void;
  34479. /**
  34480. * Creates a new index buffer
  34481. * @param indices defines the content of the index buffer
  34482. * @param updatable defines if the index buffer must be updatable
  34483. * @returns a new webGL buffer
  34484. */
  34485. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34486. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34487. /**
  34488. * Bind a webGL buffer to the webGL context
  34489. * @param buffer defines the buffer to bind
  34490. */
  34491. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34492. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34493. private bindBuffer;
  34494. /**
  34495. * update the bound buffer with the given data
  34496. * @param data defines the data to update
  34497. */
  34498. updateArrayBuffer(data: Float32Array): void;
  34499. private _vertexAttribPointer;
  34500. /** @hidden */
  34501. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34502. private _bindVertexBuffersAttributes;
  34503. /**
  34504. * Records a vertex array object
  34505. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34506. * @param vertexBuffers defines the list of vertex buffers to store
  34507. * @param indexBuffer defines the index buffer to store
  34508. * @param effect defines the effect to store
  34509. * @returns the new vertex array object
  34510. */
  34511. recordVertexArrayObject(vertexBuffers: {
  34512. [key: string]: VertexBuffer;
  34513. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34514. /**
  34515. * Bind a specific vertex array object
  34516. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34517. * @param vertexArrayObject defines the vertex array object to bind
  34518. * @param indexBuffer defines the index buffer to bind
  34519. */
  34520. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34521. /**
  34522. * Bind webGl buffers directly to the webGL context
  34523. * @param vertexBuffer defines the vertex buffer to bind
  34524. * @param indexBuffer defines the index buffer to bind
  34525. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34526. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34527. * @param effect defines the effect associated with the vertex buffer
  34528. */
  34529. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34530. private _unbindVertexArrayObject;
  34531. /**
  34532. * Bind a list of vertex buffers to the webGL context
  34533. * @param vertexBuffers defines the list of vertex buffers to bind
  34534. * @param indexBuffer defines the index buffer to bind
  34535. * @param effect defines the effect associated with the vertex buffers
  34536. */
  34537. bindBuffers(vertexBuffers: {
  34538. [key: string]: Nullable<VertexBuffer>;
  34539. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34540. /**
  34541. * Unbind all instance attributes
  34542. */
  34543. unbindInstanceAttributes(): void;
  34544. /**
  34545. * Release and free the memory of a vertex array object
  34546. * @param vao defines the vertex array object to delete
  34547. */
  34548. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34549. /** @hidden */
  34550. _releaseBuffer(buffer: DataBuffer): boolean;
  34551. protected _deleteBuffer(buffer: DataBuffer): void;
  34552. /**
  34553. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34554. * @param instancesBuffer defines the webGL buffer to update and bind
  34555. * @param data defines the data to store in the buffer
  34556. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34557. */
  34558. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34559. /**
  34560. * Bind the content of a webGL buffer used with instantiation
  34561. * @param instancesBuffer defines the webGL buffer to bind
  34562. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34563. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34564. */
  34565. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34566. /**
  34567. * Disable the instance attribute corresponding to the name in parameter
  34568. * @param name defines the name of the attribute to disable
  34569. */
  34570. disableInstanceAttributeByName(name: string): void;
  34571. /**
  34572. * Disable the instance attribute corresponding to the location in parameter
  34573. * @param attributeLocation defines the attribute location of the attribute to disable
  34574. */
  34575. disableInstanceAttribute(attributeLocation: number): void;
  34576. /**
  34577. * Disable the attribute corresponding to the location in parameter
  34578. * @param attributeLocation defines the attribute location of the attribute to disable
  34579. */
  34580. disableAttributeByIndex(attributeLocation: number): void;
  34581. /**
  34582. * Send a draw order
  34583. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34584. * @param indexStart defines the starting index
  34585. * @param indexCount defines the number of index to draw
  34586. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34587. */
  34588. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34589. /**
  34590. * Draw a list of points
  34591. * @param verticesStart defines the index of first vertex to draw
  34592. * @param verticesCount defines the count of vertices to draw
  34593. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34594. */
  34595. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34596. /**
  34597. * Draw a list of unindexed primitives
  34598. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34599. * @param verticesStart defines the index of first vertex to draw
  34600. * @param verticesCount defines the count of vertices to draw
  34601. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34602. */
  34603. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34604. /**
  34605. * Draw a list of indexed primitives
  34606. * @param fillMode defines the primitive to use
  34607. * @param indexStart defines the starting index
  34608. * @param indexCount defines the number of index to draw
  34609. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34610. */
  34611. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34612. /**
  34613. * Draw a list of unindexed primitives
  34614. * @param fillMode defines the primitive to use
  34615. * @param verticesStart defines the index of first vertex to draw
  34616. * @param verticesCount defines the count of vertices to draw
  34617. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34618. */
  34619. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34620. private _drawMode;
  34621. /** @hidden */
  34622. protected _reportDrawCall(): void;
  34623. /** @hidden */
  34624. _releaseEffect(effect: Effect): void;
  34625. /** @hidden */
  34626. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34627. /**
  34628. * Create a new effect (used to store vertex/fragment shaders)
  34629. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34630. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34631. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34632. * @param samplers defines an array of string used to represent textures
  34633. * @param defines defines the string containing the defines to use to compile the shaders
  34634. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34635. * @param onCompiled defines a function to call when the effect creation is successful
  34636. * @param onError defines a function to call when the effect creation has failed
  34637. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34638. * @returns the new Effect
  34639. */
  34640. 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;
  34641. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34642. private _compileShader;
  34643. private _compileRawShader;
  34644. /** @hidden */
  34645. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34646. /**
  34647. * Directly creates a webGL program
  34648. * @param pipelineContext defines the pipeline context to attach to
  34649. * @param vertexCode defines the vertex shader code to use
  34650. * @param fragmentCode defines the fragment shader code to use
  34651. * @param context defines the webGL context to use (if not set, the current one will be used)
  34652. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34653. * @returns the new webGL program
  34654. */
  34655. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34656. /**
  34657. * Creates a webGL program
  34658. * @param pipelineContext defines the pipeline context to attach to
  34659. * @param vertexCode defines the vertex shader code to use
  34660. * @param fragmentCode defines the fragment shader code to use
  34661. * @param defines defines the string containing the defines to use to compile the shaders
  34662. * @param context defines the webGL context to use (if not set, the current one will be used)
  34663. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34664. * @returns the new webGL program
  34665. */
  34666. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34667. /**
  34668. * Creates a new pipeline context
  34669. * @returns the new pipeline
  34670. */
  34671. createPipelineContext(): IPipelineContext;
  34672. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34673. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34674. /** @hidden */
  34675. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34676. /** @hidden */
  34677. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34678. /** @hidden */
  34679. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34680. /**
  34681. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34682. * @param pipelineContext defines the pipeline context to use
  34683. * @param uniformsNames defines the list of uniform names
  34684. * @returns an array of webGL uniform locations
  34685. */
  34686. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34687. /**
  34688. * Gets the lsit of active attributes for a given webGL program
  34689. * @param pipelineContext defines the pipeline context to use
  34690. * @param attributesNames defines the list of attribute names to get
  34691. * @returns an array of indices indicating the offset of each attribute
  34692. */
  34693. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34694. /**
  34695. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34696. * @param effect defines the effect to activate
  34697. */
  34698. enableEffect(effect: Nullable<Effect>): void;
  34699. /**
  34700. * Set the value of an uniform to a number (int)
  34701. * @param uniform defines the webGL uniform location where to store the value
  34702. * @param value defines the int number to store
  34703. */
  34704. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34705. /**
  34706. * Set the value of an uniform to an array of int32
  34707. * @param uniform defines the webGL uniform location where to store the value
  34708. * @param array defines the array of int32 to store
  34709. */
  34710. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34711. /**
  34712. * Set the value of an uniform to an array of int32 (stored as vec2)
  34713. * @param uniform defines the webGL uniform location where to store the value
  34714. * @param array defines the array of int32 to store
  34715. */
  34716. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34717. /**
  34718. * Set the value of an uniform to an array of int32 (stored as vec3)
  34719. * @param uniform defines the webGL uniform location where to store the value
  34720. * @param array defines the array of int32 to store
  34721. */
  34722. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34723. /**
  34724. * Set the value of an uniform to an array of int32 (stored as vec4)
  34725. * @param uniform defines the webGL uniform location where to store the value
  34726. * @param array defines the array of int32 to store
  34727. */
  34728. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34729. /**
  34730. * Set the value of an uniform to an array of number
  34731. * @param uniform defines the webGL uniform location where to store the value
  34732. * @param array defines the array of number to store
  34733. */
  34734. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34735. /**
  34736. * Set the value of an uniform to an array of number (stored as vec2)
  34737. * @param uniform defines the webGL uniform location where to store the value
  34738. * @param array defines the array of number to store
  34739. */
  34740. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34741. /**
  34742. * Set the value of an uniform to an array of number (stored as vec3)
  34743. * @param uniform defines the webGL uniform location where to store the value
  34744. * @param array defines the array of number to store
  34745. */
  34746. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34747. /**
  34748. * Set the value of an uniform to an array of number (stored as vec4)
  34749. * @param uniform defines the webGL uniform location where to store the value
  34750. * @param array defines the array of number to store
  34751. */
  34752. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34753. /**
  34754. * Set the value of an uniform to an array of float32 (stored as matrices)
  34755. * @param uniform defines the webGL uniform location where to store the value
  34756. * @param matrices defines the array of float32 to store
  34757. */
  34758. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  34759. /**
  34760. * Set the value of an uniform to a matrix (3x3)
  34761. * @param uniform defines the webGL uniform location where to store the value
  34762. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  34763. */
  34764. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34765. /**
  34766. * Set the value of an uniform to a matrix (2x2)
  34767. * @param uniform defines the webGL uniform location where to store the value
  34768. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  34769. */
  34770. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  34771. /**
  34772. * Set the value of an uniform to a number (float)
  34773. * @param uniform defines the webGL uniform location where to store the value
  34774. * @param value defines the float number to store
  34775. */
  34776. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34777. /**
  34778. * Set the value of an uniform to a vec2
  34779. * @param uniform defines the webGL uniform location where to store the value
  34780. * @param x defines the 1st component of the value
  34781. * @param y defines the 2nd component of the value
  34782. */
  34783. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  34784. /**
  34785. * Set the value of an uniform to a vec3
  34786. * @param uniform defines the webGL uniform location where to store the value
  34787. * @param x defines the 1st component of the value
  34788. * @param y defines the 2nd component of the value
  34789. * @param z defines the 3rd component of the value
  34790. */
  34791. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  34792. /**
  34793. * Set the value of an uniform to a vec4
  34794. * @param uniform defines the webGL uniform location where to store the value
  34795. * @param x defines the 1st component of the value
  34796. * @param y defines the 2nd component of the value
  34797. * @param z defines the 3rd component of the value
  34798. * @param w defines the 4th component of the value
  34799. */
  34800. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  34801. /**
  34802. * Apply all cached states (depth, culling, stencil and alpha)
  34803. */
  34804. applyStates(): void;
  34805. /**
  34806. * Enable or disable color writing
  34807. * @param enable defines the state to set
  34808. */
  34809. setColorWrite(enable: boolean): void;
  34810. /**
  34811. * Gets a boolean indicating if color writing is enabled
  34812. * @returns the current color writing state
  34813. */
  34814. getColorWrite(): boolean;
  34815. /**
  34816. * Gets the depth culling state manager
  34817. */
  34818. get depthCullingState(): DepthCullingState;
  34819. /**
  34820. * Gets the alpha state manager
  34821. */
  34822. get alphaState(): AlphaState;
  34823. /**
  34824. * Gets the stencil state manager
  34825. */
  34826. get stencilState(): StencilState;
  34827. /**
  34828. * Clears the list of texture accessible through engine.
  34829. * This can help preventing texture load conflict due to name collision.
  34830. */
  34831. clearInternalTexturesCache(): void;
  34832. /**
  34833. * Force the entire cache to be cleared
  34834. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  34835. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  34836. */
  34837. wipeCaches(bruteForce?: boolean): void;
  34838. /** @hidden */
  34839. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  34840. min: number;
  34841. mag: number;
  34842. };
  34843. /** @hidden */
  34844. _createTexture(): WebGLTexture;
  34845. /**
  34846. * Usually called from Texture.ts.
  34847. * Passed information to create a WebGLTexture
  34848. * @param url defines a value which contains one of the following:
  34849. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  34850. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  34851. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  34852. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  34853. * @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)
  34854. * @param scene needed for loading to the correct scene
  34855. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  34856. * @param onLoad optional callback to be called upon successful completion
  34857. * @param onError optional callback to be called upon failure
  34858. * @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
  34859. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  34860. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  34861. * @param forcedExtension defines the extension to use to pick the right loader
  34862. * @param mimeType defines an optional mime type
  34863. * @returns a InternalTexture for assignment back into BABYLON.Texture
  34864. */
  34865. 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;
  34866. /**
  34867. * Loads an image as an HTMLImageElement.
  34868. * @param input url string, ArrayBuffer, or Blob to load
  34869. * @param onLoad callback called when the image successfully loads
  34870. * @param onError callback called when the image fails to load
  34871. * @param offlineProvider offline provider for caching
  34872. * @param mimeType optional mime type
  34873. * @returns the HTMLImageElement of the loaded image
  34874. * @hidden
  34875. */
  34876. 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>;
  34877. /**
  34878. * @hidden
  34879. */
  34880. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34881. private _unpackFlipYCached;
  34882. /**
  34883. * In case you are sharing the context with other applications, it might
  34884. * be interested to not cache the unpack flip y state to ensure a consistent
  34885. * value would be set.
  34886. */
  34887. enableUnpackFlipYCached: boolean;
  34888. /** @hidden */
  34889. _unpackFlipY(value: boolean): void;
  34890. /** @hidden */
  34891. _getUnpackAlignement(): number;
  34892. private _getTextureTarget;
  34893. /**
  34894. * Update the sampling mode of a given texture
  34895. * @param samplingMode defines the required sampling mode
  34896. * @param texture defines the texture to update
  34897. * @param generateMipMaps defines whether to generate mipmaps for the texture
  34898. */
  34899. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  34900. /**
  34901. * Update the sampling mode of a given texture
  34902. * @param texture defines the texture to update
  34903. * @param wrapU defines the texture wrap mode of the u coordinates
  34904. * @param wrapV defines the texture wrap mode of the v coordinates
  34905. * @param wrapR defines the texture wrap mode of the r coordinates
  34906. */
  34907. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  34908. /** @hidden */
  34909. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  34910. width: number;
  34911. height: number;
  34912. layers?: number;
  34913. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  34914. /** @hidden */
  34915. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34916. /** @hidden */
  34917. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  34918. /**
  34919. * Update a portion of an internal texture
  34920. * @param texture defines the texture to update
  34921. * @param imageData defines the data to store into the texture
  34922. * @param xOffset defines the x coordinates of the update rectangle
  34923. * @param yOffset defines the y coordinates of the update rectangle
  34924. * @param width defines the width of the update rectangle
  34925. * @param height defines the height of the update rectangle
  34926. * @param faceIndex defines the face index if texture is a cube (0 by default)
  34927. * @param lod defines the lod level to update (0 by default)
  34928. */
  34929. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  34930. /** @hidden */
  34931. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  34932. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  34933. private _prepareWebGLTexture;
  34934. /** @hidden */
  34935. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  34936. private _getDepthStencilBuffer;
  34937. /** @hidden */
  34938. _releaseFramebufferObjects(texture: InternalTexture): void;
  34939. /** @hidden */
  34940. _releaseTexture(texture: InternalTexture): void;
  34941. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  34942. protected _setProgram(program: WebGLProgram): void;
  34943. protected _boundUniforms: {
  34944. [key: number]: WebGLUniformLocation;
  34945. };
  34946. /**
  34947. * Binds an effect to the webGL context
  34948. * @param effect defines the effect to bind
  34949. */
  34950. bindSamplers(effect: Effect): void;
  34951. private _activateCurrentTexture;
  34952. /** @hidden */
  34953. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  34954. /** @hidden */
  34955. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  34956. /**
  34957. * Unbind all textures from the webGL context
  34958. */
  34959. unbindAllTextures(): void;
  34960. /**
  34961. * Sets a texture to the according uniform.
  34962. * @param channel The texture channel
  34963. * @param uniform The uniform to set
  34964. * @param texture The texture to apply
  34965. */
  34966. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  34967. private _bindSamplerUniformToChannel;
  34968. private _getTextureWrapMode;
  34969. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  34970. /**
  34971. * Sets an array of texture to the webGL context
  34972. * @param channel defines the channel where the texture array must be set
  34973. * @param uniform defines the associated uniform location
  34974. * @param textures defines the array of textures to bind
  34975. */
  34976. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  34977. /** @hidden */
  34978. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  34979. private _setTextureParameterFloat;
  34980. private _setTextureParameterInteger;
  34981. /**
  34982. * Unbind all vertex attributes from the webGL context
  34983. */
  34984. unbindAllAttributes(): void;
  34985. /**
  34986. * 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
  34987. */
  34988. releaseEffects(): void;
  34989. /**
  34990. * Dispose and release all associated resources
  34991. */
  34992. dispose(): void;
  34993. /**
  34994. * Attach a new callback raised when context lost event is fired
  34995. * @param callback defines the callback to call
  34996. */
  34997. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  34998. /**
  34999. * Attach a new callback raised when context restored event is fired
  35000. * @param callback defines the callback to call
  35001. */
  35002. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35003. /**
  35004. * Get the current error code of the webGL context
  35005. * @returns the error code
  35006. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35007. */
  35008. getError(): number;
  35009. private _canRenderToFloatFramebuffer;
  35010. private _canRenderToHalfFloatFramebuffer;
  35011. private _canRenderToFramebuffer;
  35012. /** @hidden */
  35013. _getWebGLTextureType(type: number): number;
  35014. /** @hidden */
  35015. _getInternalFormat(format: number): number;
  35016. /** @hidden */
  35017. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35018. /** @hidden */
  35019. _getRGBAMultiSampleBufferFormat(type: number): number;
  35020. /** @hidden */
  35021. _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;
  35022. /**
  35023. * Loads a file from a url
  35024. * @param url url to load
  35025. * @param onSuccess callback called when the file successfully loads
  35026. * @param onProgress callback called while file is loading (if the server supports this mode)
  35027. * @param offlineProvider defines the offline provider for caching
  35028. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35029. * @param onError callback called when the file fails to load
  35030. * @returns a file request object
  35031. * @hidden
  35032. */
  35033. 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;
  35034. /**
  35035. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35036. * @param x defines the x coordinate of the rectangle where pixels must be read
  35037. * @param y defines the y coordinate of the rectangle where pixels must be read
  35038. * @param width defines the width of the rectangle where pixels must be read
  35039. * @param height defines the height of the rectangle where pixels must be read
  35040. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35041. * @returns a Uint8Array containing RGBA colors
  35042. */
  35043. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35044. private static _isSupported;
  35045. /**
  35046. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35047. * @returns true if the engine can be created
  35048. * @ignorenaming
  35049. */
  35050. static isSupported(): boolean;
  35051. /**
  35052. * Find the next highest power of two.
  35053. * @param x Number to start search from.
  35054. * @return Next highest power of two.
  35055. */
  35056. static CeilingPOT(x: number): number;
  35057. /**
  35058. * Find the next lowest power of two.
  35059. * @param x Number to start search from.
  35060. * @return Next lowest power of two.
  35061. */
  35062. static FloorPOT(x: number): number;
  35063. /**
  35064. * Find the nearest power of two.
  35065. * @param x Number to start search from.
  35066. * @return Next nearest power of two.
  35067. */
  35068. static NearestPOT(x: number): number;
  35069. /**
  35070. * Get the closest exponent of two
  35071. * @param value defines the value to approximate
  35072. * @param max defines the maximum value to return
  35073. * @param mode defines how to define the closest value
  35074. * @returns closest exponent of two of the given value
  35075. */
  35076. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35077. /**
  35078. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35079. * @param func - the function to be called
  35080. * @param requester - the object that will request the next frame. Falls back to window.
  35081. * @returns frame number
  35082. */
  35083. static QueueNewFrame(func: () => void, requester?: any): number;
  35084. /**
  35085. * Gets host document
  35086. * @returns the host document object
  35087. */
  35088. getHostDocument(): Nullable<Document>;
  35089. }
  35090. }
  35091. declare module BABYLON {
  35092. /**
  35093. * Class representing spherical harmonics coefficients to the 3rd degree
  35094. */
  35095. export class SphericalHarmonics {
  35096. /**
  35097. * Defines whether or not the harmonics have been prescaled for rendering.
  35098. */
  35099. preScaled: boolean;
  35100. /**
  35101. * The l0,0 coefficients of the spherical harmonics
  35102. */
  35103. l00: Vector3;
  35104. /**
  35105. * The l1,-1 coefficients of the spherical harmonics
  35106. */
  35107. l1_1: Vector3;
  35108. /**
  35109. * The l1,0 coefficients of the spherical harmonics
  35110. */
  35111. l10: Vector3;
  35112. /**
  35113. * The l1,1 coefficients of the spherical harmonics
  35114. */
  35115. l11: Vector3;
  35116. /**
  35117. * The l2,-2 coefficients of the spherical harmonics
  35118. */
  35119. l2_2: Vector3;
  35120. /**
  35121. * The l2,-1 coefficients of the spherical harmonics
  35122. */
  35123. l2_1: Vector3;
  35124. /**
  35125. * The l2,0 coefficients of the spherical harmonics
  35126. */
  35127. l20: Vector3;
  35128. /**
  35129. * The l2,1 coefficients of the spherical harmonics
  35130. */
  35131. l21: Vector3;
  35132. /**
  35133. * The l2,2 coefficients of the spherical harmonics
  35134. */
  35135. l22: Vector3;
  35136. /**
  35137. * Adds a light to the spherical harmonics
  35138. * @param direction the direction of the light
  35139. * @param color the color of the light
  35140. * @param deltaSolidAngle the delta solid angle of the light
  35141. */
  35142. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35143. /**
  35144. * Scales the spherical harmonics by the given amount
  35145. * @param scale the amount to scale
  35146. */
  35147. scaleInPlace(scale: number): void;
  35148. /**
  35149. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35150. *
  35151. * ```
  35152. * E_lm = A_l * L_lm
  35153. * ```
  35154. *
  35155. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35156. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35157. * the scaling factors are given in equation 9.
  35158. */
  35159. convertIncidentRadianceToIrradiance(): void;
  35160. /**
  35161. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35162. *
  35163. * ```
  35164. * L = (1/pi) * E * rho
  35165. * ```
  35166. *
  35167. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35168. */
  35169. convertIrradianceToLambertianRadiance(): void;
  35170. /**
  35171. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35172. * required operations at run time.
  35173. *
  35174. * This is simply done by scaling back the SH with Ylm constants parameter.
  35175. * The trigonometric part being applied by the shader at run time.
  35176. */
  35177. preScaleForRendering(): void;
  35178. /**
  35179. * Constructs a spherical harmonics from an array.
  35180. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35181. * @returns the spherical harmonics
  35182. */
  35183. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35184. /**
  35185. * Gets the spherical harmonics from polynomial
  35186. * @param polynomial the spherical polynomial
  35187. * @returns the spherical harmonics
  35188. */
  35189. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35190. }
  35191. /**
  35192. * Class representing spherical polynomial coefficients to the 3rd degree
  35193. */
  35194. export class SphericalPolynomial {
  35195. private _harmonics;
  35196. /**
  35197. * The spherical harmonics used to create the polynomials.
  35198. */
  35199. get preScaledHarmonics(): SphericalHarmonics;
  35200. /**
  35201. * The x coefficients of the spherical polynomial
  35202. */
  35203. x: Vector3;
  35204. /**
  35205. * The y coefficients of the spherical polynomial
  35206. */
  35207. y: Vector3;
  35208. /**
  35209. * The z coefficients of the spherical polynomial
  35210. */
  35211. z: Vector3;
  35212. /**
  35213. * The xx coefficients of the spherical polynomial
  35214. */
  35215. xx: Vector3;
  35216. /**
  35217. * The yy coefficients of the spherical polynomial
  35218. */
  35219. yy: Vector3;
  35220. /**
  35221. * The zz coefficients of the spherical polynomial
  35222. */
  35223. zz: Vector3;
  35224. /**
  35225. * The xy coefficients of the spherical polynomial
  35226. */
  35227. xy: Vector3;
  35228. /**
  35229. * The yz coefficients of the spherical polynomial
  35230. */
  35231. yz: Vector3;
  35232. /**
  35233. * The zx coefficients of the spherical polynomial
  35234. */
  35235. zx: Vector3;
  35236. /**
  35237. * Adds an ambient color to the spherical polynomial
  35238. * @param color the color to add
  35239. */
  35240. addAmbient(color: Color3): void;
  35241. /**
  35242. * Scales the spherical polynomial by the given amount
  35243. * @param scale the amount to scale
  35244. */
  35245. scaleInPlace(scale: number): void;
  35246. /**
  35247. * Gets the spherical polynomial from harmonics
  35248. * @param harmonics the spherical harmonics
  35249. * @returns the spherical polynomial
  35250. */
  35251. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35252. /**
  35253. * Constructs a spherical polynomial from an array.
  35254. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35255. * @returns the spherical polynomial
  35256. */
  35257. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35258. }
  35259. }
  35260. declare module BABYLON {
  35261. /**
  35262. * Defines the source of the internal texture
  35263. */
  35264. export enum InternalTextureSource {
  35265. /**
  35266. * The source of the texture data is unknown
  35267. */
  35268. Unknown = 0,
  35269. /**
  35270. * Texture data comes from an URL
  35271. */
  35272. Url = 1,
  35273. /**
  35274. * Texture data is only used for temporary storage
  35275. */
  35276. Temp = 2,
  35277. /**
  35278. * Texture data comes from raw data (ArrayBuffer)
  35279. */
  35280. Raw = 3,
  35281. /**
  35282. * Texture content is dynamic (video or dynamic texture)
  35283. */
  35284. Dynamic = 4,
  35285. /**
  35286. * Texture content is generated by rendering to it
  35287. */
  35288. RenderTarget = 5,
  35289. /**
  35290. * Texture content is part of a multi render target process
  35291. */
  35292. MultiRenderTarget = 6,
  35293. /**
  35294. * Texture data comes from a cube data file
  35295. */
  35296. Cube = 7,
  35297. /**
  35298. * Texture data comes from a raw cube data
  35299. */
  35300. CubeRaw = 8,
  35301. /**
  35302. * Texture data come from a prefiltered cube data file
  35303. */
  35304. CubePrefiltered = 9,
  35305. /**
  35306. * Texture content is raw 3D data
  35307. */
  35308. Raw3D = 10,
  35309. /**
  35310. * Texture content is raw 2D array data
  35311. */
  35312. Raw2DArray = 11,
  35313. /**
  35314. * Texture content is a depth texture
  35315. */
  35316. Depth = 12,
  35317. /**
  35318. * Texture data comes from a raw cube data encoded with RGBD
  35319. */
  35320. CubeRawRGBD = 13
  35321. }
  35322. /**
  35323. * Class used to store data associated with WebGL texture data for the engine
  35324. * This class should not be used directly
  35325. */
  35326. export class InternalTexture {
  35327. /** @hidden */
  35328. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35329. /**
  35330. * Defines if the texture is ready
  35331. */
  35332. isReady: boolean;
  35333. /**
  35334. * Defines if the texture is a cube texture
  35335. */
  35336. isCube: boolean;
  35337. /**
  35338. * Defines if the texture contains 3D data
  35339. */
  35340. is3D: boolean;
  35341. /**
  35342. * Defines if the texture contains 2D array data
  35343. */
  35344. is2DArray: boolean;
  35345. /**
  35346. * Defines if the texture contains multiview data
  35347. */
  35348. isMultiview: boolean;
  35349. /**
  35350. * Gets the URL used to load this texture
  35351. */
  35352. url: string;
  35353. /**
  35354. * Gets the sampling mode of the texture
  35355. */
  35356. samplingMode: number;
  35357. /**
  35358. * Gets a boolean indicating if the texture needs mipmaps generation
  35359. */
  35360. generateMipMaps: boolean;
  35361. /**
  35362. * Gets the number of samples used by the texture (WebGL2+ only)
  35363. */
  35364. samples: number;
  35365. /**
  35366. * Gets the type of the texture (int, float...)
  35367. */
  35368. type: number;
  35369. /**
  35370. * Gets the format of the texture (RGB, RGBA...)
  35371. */
  35372. format: number;
  35373. /**
  35374. * Observable called when the texture is loaded
  35375. */
  35376. onLoadedObservable: Observable<InternalTexture>;
  35377. /**
  35378. * Gets the width of the texture
  35379. */
  35380. width: number;
  35381. /**
  35382. * Gets the height of the texture
  35383. */
  35384. height: number;
  35385. /**
  35386. * Gets the depth of the texture
  35387. */
  35388. depth: number;
  35389. /**
  35390. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35391. */
  35392. baseWidth: number;
  35393. /**
  35394. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35395. */
  35396. baseHeight: number;
  35397. /**
  35398. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35399. */
  35400. baseDepth: number;
  35401. /**
  35402. * Gets a boolean indicating if the texture is inverted on Y axis
  35403. */
  35404. invertY: boolean;
  35405. /** @hidden */
  35406. _invertVScale: boolean;
  35407. /** @hidden */
  35408. _associatedChannel: number;
  35409. /** @hidden */
  35410. _source: InternalTextureSource;
  35411. /** @hidden */
  35412. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35413. /** @hidden */
  35414. _bufferView: Nullable<ArrayBufferView>;
  35415. /** @hidden */
  35416. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35417. /** @hidden */
  35418. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35419. /** @hidden */
  35420. _size: number;
  35421. /** @hidden */
  35422. _extension: string;
  35423. /** @hidden */
  35424. _files: Nullable<string[]>;
  35425. /** @hidden */
  35426. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35427. /** @hidden */
  35428. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35429. /** @hidden */
  35430. _framebuffer: Nullable<WebGLFramebuffer>;
  35431. /** @hidden */
  35432. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35433. /** @hidden */
  35434. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35435. /** @hidden */
  35436. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35437. /** @hidden */
  35438. _attachments: Nullable<number[]>;
  35439. /** @hidden */
  35440. _cachedCoordinatesMode: Nullable<number>;
  35441. /** @hidden */
  35442. _cachedWrapU: Nullable<number>;
  35443. /** @hidden */
  35444. _cachedWrapV: Nullable<number>;
  35445. /** @hidden */
  35446. _cachedWrapR: Nullable<number>;
  35447. /** @hidden */
  35448. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35449. /** @hidden */
  35450. _isDisabled: boolean;
  35451. /** @hidden */
  35452. _compression: Nullable<string>;
  35453. /** @hidden */
  35454. _generateStencilBuffer: boolean;
  35455. /** @hidden */
  35456. _generateDepthBuffer: boolean;
  35457. /** @hidden */
  35458. _comparisonFunction: number;
  35459. /** @hidden */
  35460. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35461. /** @hidden */
  35462. _lodGenerationScale: number;
  35463. /** @hidden */
  35464. _lodGenerationOffset: number;
  35465. /** @hidden */
  35466. _depthStencilTexture: Nullable<InternalTexture>;
  35467. /** @hidden */
  35468. _colorTextureArray: Nullable<WebGLTexture>;
  35469. /** @hidden */
  35470. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35471. /** @hidden */
  35472. _lodTextureHigh: Nullable<BaseTexture>;
  35473. /** @hidden */
  35474. _lodTextureMid: Nullable<BaseTexture>;
  35475. /** @hidden */
  35476. _lodTextureLow: Nullable<BaseTexture>;
  35477. /** @hidden */
  35478. _isRGBD: boolean;
  35479. /** @hidden */
  35480. _linearSpecularLOD: boolean;
  35481. /** @hidden */
  35482. _irradianceTexture: Nullable<BaseTexture>;
  35483. /** @hidden */
  35484. _webGLTexture: Nullable<WebGLTexture>;
  35485. /** @hidden */
  35486. _references: number;
  35487. private _engine;
  35488. /**
  35489. * Gets the Engine the texture belongs to.
  35490. * @returns The babylon engine
  35491. */
  35492. getEngine(): ThinEngine;
  35493. /**
  35494. * Gets the data source type of the texture
  35495. */
  35496. get source(): InternalTextureSource;
  35497. /**
  35498. * Creates a new InternalTexture
  35499. * @param engine defines the engine to use
  35500. * @param source defines the type of data that will be used
  35501. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35502. */
  35503. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35504. /**
  35505. * Increments the number of references (ie. the number of Texture that point to it)
  35506. */
  35507. incrementReferences(): void;
  35508. /**
  35509. * Change the size of the texture (not the size of the content)
  35510. * @param width defines the new width
  35511. * @param height defines the new height
  35512. * @param depth defines the new depth (1 by default)
  35513. */
  35514. updateSize(width: int, height: int, depth?: int): void;
  35515. /** @hidden */
  35516. _rebuild(): void;
  35517. /** @hidden */
  35518. _swapAndDie(target: InternalTexture): void;
  35519. /**
  35520. * Dispose the current allocated resources
  35521. */
  35522. dispose(): void;
  35523. }
  35524. }
  35525. declare module BABYLON {
  35526. /**
  35527. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35529. */
  35530. export class Analyser {
  35531. /**
  35532. * Gets or sets the smoothing
  35533. * @ignorenaming
  35534. */
  35535. SMOOTHING: number;
  35536. /**
  35537. * Gets or sets the FFT table size
  35538. * @ignorenaming
  35539. */
  35540. FFT_SIZE: number;
  35541. /**
  35542. * Gets or sets the bar graph amplitude
  35543. * @ignorenaming
  35544. */
  35545. BARGRAPHAMPLITUDE: number;
  35546. /**
  35547. * Gets or sets the position of the debug canvas
  35548. * @ignorenaming
  35549. */
  35550. DEBUGCANVASPOS: {
  35551. x: number;
  35552. y: number;
  35553. };
  35554. /**
  35555. * Gets or sets the debug canvas size
  35556. * @ignorenaming
  35557. */
  35558. DEBUGCANVASSIZE: {
  35559. width: number;
  35560. height: number;
  35561. };
  35562. private _byteFreqs;
  35563. private _byteTime;
  35564. private _floatFreqs;
  35565. private _webAudioAnalyser;
  35566. private _debugCanvas;
  35567. private _debugCanvasContext;
  35568. private _scene;
  35569. private _registerFunc;
  35570. private _audioEngine;
  35571. /**
  35572. * Creates a new analyser
  35573. * @param scene defines hosting scene
  35574. */
  35575. constructor(scene: Scene);
  35576. /**
  35577. * Get the number of data values you will have to play with for the visualization
  35578. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35579. * @returns a number
  35580. */
  35581. getFrequencyBinCount(): number;
  35582. /**
  35583. * Gets the current frequency data as a byte array
  35584. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35585. * @returns a Uint8Array
  35586. */
  35587. getByteFrequencyData(): Uint8Array;
  35588. /**
  35589. * Gets the current waveform as a byte array
  35590. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35591. * @returns a Uint8Array
  35592. */
  35593. getByteTimeDomainData(): Uint8Array;
  35594. /**
  35595. * Gets the current frequency data as a float array
  35596. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35597. * @returns a Float32Array
  35598. */
  35599. getFloatFrequencyData(): Float32Array;
  35600. /**
  35601. * Renders the debug canvas
  35602. */
  35603. drawDebugCanvas(): void;
  35604. /**
  35605. * Stops rendering the debug canvas and removes it
  35606. */
  35607. stopDebugCanvas(): void;
  35608. /**
  35609. * Connects two audio nodes
  35610. * @param inputAudioNode defines first node to connect
  35611. * @param outputAudioNode defines second node to connect
  35612. */
  35613. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35614. /**
  35615. * Releases all associated resources
  35616. */
  35617. dispose(): void;
  35618. }
  35619. }
  35620. declare module BABYLON {
  35621. /**
  35622. * This represents an audio engine and it is responsible
  35623. * to play, synchronize and analyse sounds throughout the application.
  35624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35625. */
  35626. export interface IAudioEngine extends IDisposable {
  35627. /**
  35628. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35629. */
  35630. readonly canUseWebAudio: boolean;
  35631. /**
  35632. * Gets the current AudioContext if available.
  35633. */
  35634. readonly audioContext: Nullable<AudioContext>;
  35635. /**
  35636. * The master gain node defines the global audio volume of your audio engine.
  35637. */
  35638. readonly masterGain: GainNode;
  35639. /**
  35640. * Gets whether or not mp3 are supported by your browser.
  35641. */
  35642. readonly isMP3supported: boolean;
  35643. /**
  35644. * Gets whether or not ogg are supported by your browser.
  35645. */
  35646. readonly isOGGsupported: boolean;
  35647. /**
  35648. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35649. * @ignoreNaming
  35650. */
  35651. WarnedWebAudioUnsupported: boolean;
  35652. /**
  35653. * Defines if the audio engine relies on a custom unlocked button.
  35654. * In this case, the embedded button will not be displayed.
  35655. */
  35656. useCustomUnlockedButton: boolean;
  35657. /**
  35658. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35659. */
  35660. readonly unlocked: boolean;
  35661. /**
  35662. * Event raised when audio has been unlocked on the browser.
  35663. */
  35664. onAudioUnlockedObservable: Observable<AudioEngine>;
  35665. /**
  35666. * Event raised when audio has been locked on the browser.
  35667. */
  35668. onAudioLockedObservable: Observable<AudioEngine>;
  35669. /**
  35670. * Flags the audio engine in Locked state.
  35671. * This happens due to new browser policies preventing audio to autoplay.
  35672. */
  35673. lock(): void;
  35674. /**
  35675. * Unlocks the audio engine once a user action has been done on the dom.
  35676. * This is helpful to resume play once browser policies have been satisfied.
  35677. */
  35678. unlock(): void;
  35679. /**
  35680. * Gets the global volume sets on the master gain.
  35681. * @returns the global volume if set or -1 otherwise
  35682. */
  35683. getGlobalVolume(): number;
  35684. /**
  35685. * Sets the global volume of your experience (sets on the master gain).
  35686. * @param newVolume Defines the new global volume of the application
  35687. */
  35688. setGlobalVolume(newVolume: number): void;
  35689. /**
  35690. * Connect the audio engine to an audio analyser allowing some amazing
  35691. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35693. * @param analyser The analyser to connect to the engine
  35694. */
  35695. connectToAnalyser(analyser: Analyser): void;
  35696. }
  35697. /**
  35698. * This represents the default audio engine used in babylon.
  35699. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35701. */
  35702. export class AudioEngine implements IAudioEngine {
  35703. private _audioContext;
  35704. private _audioContextInitialized;
  35705. private _muteButton;
  35706. private _hostElement;
  35707. /**
  35708. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35709. */
  35710. canUseWebAudio: boolean;
  35711. /**
  35712. * The master gain node defines the global audio volume of your audio engine.
  35713. */
  35714. masterGain: GainNode;
  35715. /**
  35716. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35717. * @ignoreNaming
  35718. */
  35719. WarnedWebAudioUnsupported: boolean;
  35720. /**
  35721. * Gets whether or not mp3 are supported by your browser.
  35722. */
  35723. isMP3supported: boolean;
  35724. /**
  35725. * Gets whether or not ogg are supported by your browser.
  35726. */
  35727. isOGGsupported: boolean;
  35728. /**
  35729. * Gets whether audio has been unlocked on the device.
  35730. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35731. * a user interaction has happened.
  35732. */
  35733. unlocked: boolean;
  35734. /**
  35735. * Defines if the audio engine relies on a custom unlocked button.
  35736. * In this case, the embedded button will not be displayed.
  35737. */
  35738. useCustomUnlockedButton: boolean;
  35739. /**
  35740. * Event raised when audio has been unlocked on the browser.
  35741. */
  35742. onAudioUnlockedObservable: Observable<AudioEngine>;
  35743. /**
  35744. * Event raised when audio has been locked on the browser.
  35745. */
  35746. onAudioLockedObservable: Observable<AudioEngine>;
  35747. /**
  35748. * Gets the current AudioContext if available.
  35749. */
  35750. get audioContext(): Nullable<AudioContext>;
  35751. private _connectedAnalyser;
  35752. /**
  35753. * Instantiates a new audio engine.
  35754. *
  35755. * There should be only one per page as some browsers restrict the number
  35756. * of audio contexts you can create.
  35757. * @param hostElement defines the host element where to display the mute icon if necessary
  35758. */
  35759. constructor(hostElement?: Nullable<HTMLElement>);
  35760. /**
  35761. * Flags the audio engine in Locked state.
  35762. * This happens due to new browser policies preventing audio to autoplay.
  35763. */
  35764. lock(): void;
  35765. /**
  35766. * Unlocks the audio engine once a user action has been done on the dom.
  35767. * This is helpful to resume play once browser policies have been satisfied.
  35768. */
  35769. unlock(): void;
  35770. private _resumeAudioContext;
  35771. private _initializeAudioContext;
  35772. private _tryToRun;
  35773. private _triggerRunningState;
  35774. private _triggerSuspendedState;
  35775. private _displayMuteButton;
  35776. private _moveButtonToTopLeft;
  35777. private _onResize;
  35778. private _hideMuteButton;
  35779. /**
  35780. * Destroy and release the resources associated with the audio ccontext.
  35781. */
  35782. dispose(): void;
  35783. /**
  35784. * Gets the global volume sets on the master gain.
  35785. * @returns the global volume if set or -1 otherwise
  35786. */
  35787. getGlobalVolume(): number;
  35788. /**
  35789. * Sets the global volume of your experience (sets on the master gain).
  35790. * @param newVolume Defines the new global volume of the application
  35791. */
  35792. setGlobalVolume(newVolume: number): void;
  35793. /**
  35794. * Connect the audio engine to an audio analyser allowing some amazing
  35795. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35797. * @param analyser The analyser to connect to the engine
  35798. */
  35799. connectToAnalyser(analyser: Analyser): void;
  35800. }
  35801. }
  35802. declare module BABYLON {
  35803. /**
  35804. * Interface used to present a loading screen while loading a scene
  35805. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35806. */
  35807. export interface ILoadingScreen {
  35808. /**
  35809. * Function called to display the loading screen
  35810. */
  35811. displayLoadingUI: () => void;
  35812. /**
  35813. * Function called to hide the loading screen
  35814. */
  35815. hideLoadingUI: () => void;
  35816. /**
  35817. * Gets or sets the color to use for the background
  35818. */
  35819. loadingUIBackgroundColor: string;
  35820. /**
  35821. * Gets or sets the text to display while loading
  35822. */
  35823. loadingUIText: string;
  35824. }
  35825. /**
  35826. * Class used for the default loading screen
  35827. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35828. */
  35829. export class DefaultLoadingScreen implements ILoadingScreen {
  35830. private _renderingCanvas;
  35831. private _loadingText;
  35832. private _loadingDivBackgroundColor;
  35833. private _loadingDiv;
  35834. private _loadingTextDiv;
  35835. /** Gets or sets the logo url to use for the default loading screen */
  35836. static DefaultLogoUrl: string;
  35837. /** Gets or sets the spinner url to use for the default loading screen */
  35838. static DefaultSpinnerUrl: string;
  35839. /**
  35840. * Creates a new default loading screen
  35841. * @param _renderingCanvas defines the canvas used to render the scene
  35842. * @param _loadingText defines the default text to display
  35843. * @param _loadingDivBackgroundColor defines the default background color
  35844. */
  35845. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  35846. /**
  35847. * Function called to display the loading screen
  35848. */
  35849. displayLoadingUI(): void;
  35850. /**
  35851. * Function called to hide the loading screen
  35852. */
  35853. hideLoadingUI(): void;
  35854. /**
  35855. * Gets or sets the text to display while loading
  35856. */
  35857. set loadingUIText(text: string);
  35858. get loadingUIText(): string;
  35859. /**
  35860. * Gets or sets the color to use for the background
  35861. */
  35862. get loadingUIBackgroundColor(): string;
  35863. set loadingUIBackgroundColor(color: string);
  35864. private _resizeLoadingUI;
  35865. }
  35866. }
  35867. declare module BABYLON {
  35868. /**
  35869. * Interface for any object that can request an animation frame
  35870. */
  35871. export interface ICustomAnimationFrameRequester {
  35872. /**
  35873. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  35874. */
  35875. renderFunction?: Function;
  35876. /**
  35877. * Called to request the next frame to render to
  35878. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  35879. */
  35880. requestAnimationFrame: Function;
  35881. /**
  35882. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  35883. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  35884. */
  35885. requestID?: number;
  35886. }
  35887. }
  35888. declare module BABYLON {
  35889. /**
  35890. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  35891. */
  35892. export class PerformanceMonitor {
  35893. private _enabled;
  35894. private _rollingFrameTime;
  35895. private _lastFrameTimeMs;
  35896. /**
  35897. * constructor
  35898. * @param frameSampleSize The number of samples required to saturate the sliding window
  35899. */
  35900. constructor(frameSampleSize?: number);
  35901. /**
  35902. * Samples current frame
  35903. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  35904. */
  35905. sampleFrame(timeMs?: number): void;
  35906. /**
  35907. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35908. */
  35909. get averageFrameTime(): number;
  35910. /**
  35911. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  35912. */
  35913. get averageFrameTimeVariance(): number;
  35914. /**
  35915. * Returns the frame time of the most recent frame
  35916. */
  35917. get instantaneousFrameTime(): number;
  35918. /**
  35919. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  35920. */
  35921. get averageFPS(): number;
  35922. /**
  35923. * Returns the average framerate in frames per second using the most recent frame time
  35924. */
  35925. get instantaneousFPS(): number;
  35926. /**
  35927. * Returns true if enough samples have been taken to completely fill the sliding window
  35928. */
  35929. get isSaturated(): boolean;
  35930. /**
  35931. * Enables contributions to the sliding window sample set
  35932. */
  35933. enable(): void;
  35934. /**
  35935. * Disables contributions to the sliding window sample set
  35936. * Samples will not be interpolated over the disabled period
  35937. */
  35938. disable(): void;
  35939. /**
  35940. * Returns true if sampling is enabled
  35941. */
  35942. get isEnabled(): boolean;
  35943. /**
  35944. * Resets performance monitor
  35945. */
  35946. reset(): void;
  35947. }
  35948. /**
  35949. * RollingAverage
  35950. *
  35951. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  35952. */
  35953. export class RollingAverage {
  35954. /**
  35955. * Current average
  35956. */
  35957. average: number;
  35958. /**
  35959. * Current variance
  35960. */
  35961. variance: number;
  35962. protected _samples: Array<number>;
  35963. protected _sampleCount: number;
  35964. protected _pos: number;
  35965. protected _m2: number;
  35966. /**
  35967. * constructor
  35968. * @param length The number of samples required to saturate the sliding window
  35969. */
  35970. constructor(length: number);
  35971. /**
  35972. * Adds a sample to the sample set
  35973. * @param v The sample value
  35974. */
  35975. add(v: number): void;
  35976. /**
  35977. * Returns previously added values or null if outside of history or outside the sliding window domain
  35978. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  35979. * @return Value previously recorded with add() or null if outside of range
  35980. */
  35981. history(i: number): number;
  35982. /**
  35983. * Returns true if enough samples have been taken to completely fill the sliding window
  35984. * @return true if sample-set saturated
  35985. */
  35986. isSaturated(): boolean;
  35987. /**
  35988. * Resets the rolling average (equivalent to 0 samples taken so far)
  35989. */
  35990. reset(): void;
  35991. /**
  35992. * Wraps a value around the sample range boundaries
  35993. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  35994. * @return Wrapped position in sample range
  35995. */
  35996. protected _wrapPosition(i: number): number;
  35997. }
  35998. }
  35999. declare module BABYLON {
  36000. /**
  36001. * This class is used to track a performance counter which is number based.
  36002. * The user has access to many properties which give statistics of different nature.
  36003. *
  36004. * The implementer can track two kinds of Performance Counter: time and count.
  36005. * 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.
  36006. * 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.
  36007. */
  36008. export class PerfCounter {
  36009. /**
  36010. * Gets or sets a global boolean to turn on and off all the counters
  36011. */
  36012. static Enabled: boolean;
  36013. /**
  36014. * Returns the smallest value ever
  36015. */
  36016. get min(): number;
  36017. /**
  36018. * Returns the biggest value ever
  36019. */
  36020. get max(): number;
  36021. /**
  36022. * Returns the average value since the performance counter is running
  36023. */
  36024. get average(): number;
  36025. /**
  36026. * Returns the average value of the last second the counter was monitored
  36027. */
  36028. get lastSecAverage(): number;
  36029. /**
  36030. * Returns the current value
  36031. */
  36032. get current(): number;
  36033. /**
  36034. * Gets the accumulated total
  36035. */
  36036. get total(): number;
  36037. /**
  36038. * Gets the total value count
  36039. */
  36040. get count(): number;
  36041. /**
  36042. * Creates a new counter
  36043. */
  36044. constructor();
  36045. /**
  36046. * Call this method to start monitoring a new frame.
  36047. * 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.
  36048. */
  36049. fetchNewFrame(): void;
  36050. /**
  36051. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36052. * @param newCount the count value to add to the monitored count
  36053. * @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.
  36054. */
  36055. addCount(newCount: number, fetchResult: boolean): void;
  36056. /**
  36057. * Start monitoring this performance counter
  36058. */
  36059. beginMonitoring(): void;
  36060. /**
  36061. * Compute the time lapsed since the previous beginMonitoring() call.
  36062. * @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
  36063. */
  36064. endMonitoring(newFrame?: boolean): void;
  36065. private _fetchResult;
  36066. private _startMonitoringTime;
  36067. private _min;
  36068. private _max;
  36069. private _average;
  36070. private _current;
  36071. private _totalValueCount;
  36072. private _totalAccumulated;
  36073. private _lastSecAverage;
  36074. private _lastSecAccumulated;
  36075. private _lastSecTime;
  36076. private _lastSecValueCount;
  36077. }
  36078. }
  36079. declare module BABYLON {
  36080. interface ThinEngine {
  36081. /**
  36082. * Sets alpha constants used by some alpha blending modes
  36083. * @param r defines the red component
  36084. * @param g defines the green component
  36085. * @param b defines the blue component
  36086. * @param a defines the alpha component
  36087. */
  36088. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36089. /**
  36090. * Sets the current alpha mode
  36091. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36092. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36093. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36094. */
  36095. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36096. /**
  36097. * Gets the current alpha mode
  36098. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36099. * @returns the current alpha mode
  36100. */
  36101. getAlphaMode(): number;
  36102. /**
  36103. * Sets the current alpha equation
  36104. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36105. */
  36106. setAlphaEquation(equation: number): void;
  36107. /**
  36108. * Gets the current alpha equation.
  36109. * @returns the current alpha equation
  36110. */
  36111. getAlphaEquation(): number;
  36112. }
  36113. }
  36114. declare module BABYLON {
  36115. interface ThinEngine {
  36116. /** @hidden */
  36117. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36118. }
  36119. }
  36120. declare module BABYLON {
  36121. /**
  36122. * Defines the interface used by display changed events
  36123. */
  36124. export interface IDisplayChangedEventArgs {
  36125. /** Gets the vrDisplay object (if any) */
  36126. vrDisplay: Nullable<any>;
  36127. /** Gets a boolean indicating if webVR is supported */
  36128. vrSupported: boolean;
  36129. }
  36130. /**
  36131. * Defines the interface used by objects containing a viewport (like a camera)
  36132. */
  36133. interface IViewportOwnerLike {
  36134. /**
  36135. * Gets or sets the viewport
  36136. */
  36137. viewport: IViewportLike;
  36138. }
  36139. /**
  36140. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36141. */
  36142. export class Engine extends ThinEngine {
  36143. /** Defines that alpha blending is disabled */
  36144. static readonly ALPHA_DISABLE: number;
  36145. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36146. static readonly ALPHA_ADD: number;
  36147. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36148. static readonly ALPHA_COMBINE: number;
  36149. /** Defines that alpha blending to DEST - SRC * DEST */
  36150. static readonly ALPHA_SUBTRACT: number;
  36151. /** Defines that alpha blending to SRC * DEST */
  36152. static readonly ALPHA_MULTIPLY: number;
  36153. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36154. static readonly ALPHA_MAXIMIZED: number;
  36155. /** Defines that alpha blending to SRC + DEST */
  36156. static readonly ALPHA_ONEONE: number;
  36157. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36158. static readonly ALPHA_PREMULTIPLIED: number;
  36159. /**
  36160. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36161. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36162. */
  36163. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36164. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36165. static readonly ALPHA_INTERPOLATE: number;
  36166. /**
  36167. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36168. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36169. */
  36170. static readonly ALPHA_SCREENMODE: number;
  36171. /** Defines that the ressource is not delayed*/
  36172. static readonly DELAYLOADSTATE_NONE: number;
  36173. /** Defines that the ressource was successfully delay loaded */
  36174. static readonly DELAYLOADSTATE_LOADED: number;
  36175. /** Defines that the ressource is currently delay loading */
  36176. static readonly DELAYLOADSTATE_LOADING: number;
  36177. /** Defines that the ressource is delayed and has not started loading */
  36178. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36179. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36180. static readonly NEVER: number;
  36181. /** 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 */
  36182. static readonly ALWAYS: number;
  36183. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36184. static readonly LESS: number;
  36185. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36186. static readonly EQUAL: number;
  36187. /** 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 */
  36188. static readonly LEQUAL: number;
  36189. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36190. static readonly GREATER: number;
  36191. /** 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 */
  36192. static readonly GEQUAL: number;
  36193. /** 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 */
  36194. static readonly NOTEQUAL: number;
  36195. /** Passed to stencilOperation to specify that stencil value must be kept */
  36196. static readonly KEEP: number;
  36197. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36198. static readonly REPLACE: number;
  36199. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36200. static readonly INCR: number;
  36201. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36202. static readonly DECR: number;
  36203. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36204. static readonly INVERT: number;
  36205. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36206. static readonly INCR_WRAP: number;
  36207. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36208. static readonly DECR_WRAP: number;
  36209. /** Texture is not repeating outside of 0..1 UVs */
  36210. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36211. /** Texture is repeating outside of 0..1 UVs */
  36212. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36213. /** Texture is repeating and mirrored */
  36214. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36215. /** ALPHA */
  36216. static readonly TEXTUREFORMAT_ALPHA: number;
  36217. /** LUMINANCE */
  36218. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36219. /** LUMINANCE_ALPHA */
  36220. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36221. /** RGB */
  36222. static readonly TEXTUREFORMAT_RGB: number;
  36223. /** RGBA */
  36224. static readonly TEXTUREFORMAT_RGBA: number;
  36225. /** RED */
  36226. static readonly TEXTUREFORMAT_RED: number;
  36227. /** RED (2nd reference) */
  36228. static readonly TEXTUREFORMAT_R: number;
  36229. /** RG */
  36230. static readonly TEXTUREFORMAT_RG: number;
  36231. /** RED_INTEGER */
  36232. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36233. /** RED_INTEGER (2nd reference) */
  36234. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36235. /** RG_INTEGER */
  36236. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36237. /** RGB_INTEGER */
  36238. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36239. /** RGBA_INTEGER */
  36240. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36241. /** UNSIGNED_BYTE */
  36242. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36243. /** UNSIGNED_BYTE (2nd reference) */
  36244. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36245. /** FLOAT */
  36246. static readonly TEXTURETYPE_FLOAT: number;
  36247. /** HALF_FLOAT */
  36248. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36249. /** BYTE */
  36250. static readonly TEXTURETYPE_BYTE: number;
  36251. /** SHORT */
  36252. static readonly TEXTURETYPE_SHORT: number;
  36253. /** UNSIGNED_SHORT */
  36254. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36255. /** INT */
  36256. static readonly TEXTURETYPE_INT: number;
  36257. /** UNSIGNED_INT */
  36258. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36259. /** UNSIGNED_SHORT_4_4_4_4 */
  36260. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36261. /** UNSIGNED_SHORT_5_5_5_1 */
  36262. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36263. /** UNSIGNED_SHORT_5_6_5 */
  36264. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36265. /** UNSIGNED_INT_2_10_10_10_REV */
  36266. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36267. /** UNSIGNED_INT_24_8 */
  36268. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36269. /** UNSIGNED_INT_10F_11F_11F_REV */
  36270. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36271. /** UNSIGNED_INT_5_9_9_9_REV */
  36272. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36273. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36274. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36275. /** nearest is mag = nearest and min = nearest and mip = linear */
  36276. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36277. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36278. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36279. /** Trilinear is mag = linear and min = linear and mip = linear */
  36280. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36281. /** nearest is mag = nearest and min = nearest and mip = linear */
  36282. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36283. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36284. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36285. /** Trilinear is mag = linear and min = linear and mip = linear */
  36286. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36287. /** mag = nearest and min = nearest and mip = nearest */
  36288. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36289. /** mag = nearest and min = linear and mip = nearest */
  36290. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36291. /** mag = nearest and min = linear and mip = linear */
  36292. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36293. /** mag = nearest and min = linear and mip = none */
  36294. static readonly TEXTURE_NEAREST_LINEAR: number;
  36295. /** mag = nearest and min = nearest and mip = none */
  36296. static readonly TEXTURE_NEAREST_NEAREST: number;
  36297. /** mag = linear and min = nearest and mip = nearest */
  36298. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36299. /** mag = linear and min = nearest and mip = linear */
  36300. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36301. /** mag = linear and min = linear and mip = none */
  36302. static readonly TEXTURE_LINEAR_LINEAR: number;
  36303. /** mag = linear and min = nearest and mip = none */
  36304. static readonly TEXTURE_LINEAR_NEAREST: number;
  36305. /** Explicit coordinates mode */
  36306. static readonly TEXTURE_EXPLICIT_MODE: number;
  36307. /** Spherical coordinates mode */
  36308. static readonly TEXTURE_SPHERICAL_MODE: number;
  36309. /** Planar coordinates mode */
  36310. static readonly TEXTURE_PLANAR_MODE: number;
  36311. /** Cubic coordinates mode */
  36312. static readonly TEXTURE_CUBIC_MODE: number;
  36313. /** Projection coordinates mode */
  36314. static readonly TEXTURE_PROJECTION_MODE: number;
  36315. /** Skybox coordinates mode */
  36316. static readonly TEXTURE_SKYBOX_MODE: number;
  36317. /** Inverse Cubic coordinates mode */
  36318. static readonly TEXTURE_INVCUBIC_MODE: number;
  36319. /** Equirectangular coordinates mode */
  36320. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36321. /** Equirectangular Fixed coordinates mode */
  36322. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36323. /** Equirectangular Fixed Mirrored coordinates mode */
  36324. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36325. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36326. static readonly SCALEMODE_FLOOR: number;
  36327. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36328. static readonly SCALEMODE_NEAREST: number;
  36329. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36330. static readonly SCALEMODE_CEILING: number;
  36331. /**
  36332. * Returns the current npm package of the sdk
  36333. */
  36334. static get NpmPackage(): string;
  36335. /**
  36336. * Returns the current version of the framework
  36337. */
  36338. static get Version(): string;
  36339. /** Gets the list of created engines */
  36340. static get Instances(): Engine[];
  36341. /**
  36342. * Gets the latest created engine
  36343. */
  36344. static get LastCreatedEngine(): Nullable<Engine>;
  36345. /**
  36346. * Gets the latest created scene
  36347. */
  36348. static get LastCreatedScene(): Nullable<Scene>;
  36349. /**
  36350. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36351. * @param flag defines which part of the materials must be marked as dirty
  36352. * @param predicate defines a predicate used to filter which materials should be affected
  36353. */
  36354. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36355. /**
  36356. * Method called to create the default loading screen.
  36357. * This can be overriden in your own app.
  36358. * @param canvas The rendering canvas element
  36359. * @returns The loading screen
  36360. */
  36361. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36362. /**
  36363. * Method called to create the default rescale post process on each engine.
  36364. */
  36365. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36366. /**
  36367. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36368. **/
  36369. enableOfflineSupport: boolean;
  36370. /**
  36371. * 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)
  36372. **/
  36373. disableManifestCheck: boolean;
  36374. /**
  36375. * Gets the list of created scenes
  36376. */
  36377. scenes: Scene[];
  36378. /**
  36379. * Event raised when a new scene is created
  36380. */
  36381. onNewSceneAddedObservable: Observable<Scene>;
  36382. /**
  36383. * Gets the list of created postprocesses
  36384. */
  36385. postProcesses: PostProcess[];
  36386. /**
  36387. * Gets a boolean indicating if the pointer is currently locked
  36388. */
  36389. isPointerLock: boolean;
  36390. /**
  36391. * Observable event triggered each time the rendering canvas is resized
  36392. */
  36393. onResizeObservable: Observable<Engine>;
  36394. /**
  36395. * Observable event triggered each time the canvas loses focus
  36396. */
  36397. onCanvasBlurObservable: Observable<Engine>;
  36398. /**
  36399. * Observable event triggered each time the canvas gains focus
  36400. */
  36401. onCanvasFocusObservable: Observable<Engine>;
  36402. /**
  36403. * Observable event triggered each time the canvas receives pointerout event
  36404. */
  36405. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36406. /**
  36407. * Observable raised when the engine begins a new frame
  36408. */
  36409. onBeginFrameObservable: Observable<Engine>;
  36410. /**
  36411. * If set, will be used to request the next animation frame for the render loop
  36412. */
  36413. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36414. /**
  36415. * Observable raised when the engine ends the current frame
  36416. */
  36417. onEndFrameObservable: Observable<Engine>;
  36418. /**
  36419. * Observable raised when the engine is about to compile a shader
  36420. */
  36421. onBeforeShaderCompilationObservable: Observable<Engine>;
  36422. /**
  36423. * Observable raised when the engine has jsut compiled a shader
  36424. */
  36425. onAfterShaderCompilationObservable: Observable<Engine>;
  36426. /**
  36427. * Gets the audio engine
  36428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36429. * @ignorenaming
  36430. */
  36431. static audioEngine: IAudioEngine;
  36432. /**
  36433. * Default AudioEngine factory responsible of creating the Audio Engine.
  36434. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36435. */
  36436. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36437. /**
  36438. * Default offline support factory responsible of creating a tool used to store data locally.
  36439. * By default, this will create a Database object if the workload has been embedded.
  36440. */
  36441. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36442. private _loadingScreen;
  36443. private _pointerLockRequested;
  36444. private _rescalePostProcess;
  36445. private _deterministicLockstep;
  36446. private _lockstepMaxSteps;
  36447. private _timeStep;
  36448. protected get _supportsHardwareTextureRescaling(): boolean;
  36449. private _fps;
  36450. private _deltaTime;
  36451. /** @hidden */
  36452. _drawCalls: PerfCounter;
  36453. /** 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 */
  36454. canvasTabIndex: number;
  36455. /**
  36456. * Turn this value on if you want to pause FPS computation when in background
  36457. */
  36458. disablePerformanceMonitorInBackground: boolean;
  36459. private _performanceMonitor;
  36460. /**
  36461. * Gets the performance monitor attached to this engine
  36462. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36463. */
  36464. get performanceMonitor(): PerformanceMonitor;
  36465. private _onFocus;
  36466. private _onBlur;
  36467. private _onCanvasPointerOut;
  36468. private _onCanvasBlur;
  36469. private _onCanvasFocus;
  36470. private _onFullscreenChange;
  36471. private _onPointerLockChange;
  36472. /**
  36473. * Gets the HTML element used to attach event listeners
  36474. * @returns a HTML element
  36475. */
  36476. getInputElement(): Nullable<HTMLElement>;
  36477. /**
  36478. * Creates a new engine
  36479. * @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
  36480. * @param antialias defines enable antialiasing (default: false)
  36481. * @param options defines further options to be sent to the getContext() function
  36482. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36483. */
  36484. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36485. /**
  36486. * Gets current aspect ratio
  36487. * @param viewportOwner defines the camera to use to get the aspect ratio
  36488. * @param useScreen defines if screen size must be used (or the current render target if any)
  36489. * @returns a number defining the aspect ratio
  36490. */
  36491. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36492. /**
  36493. * Gets current screen aspect ratio
  36494. * @returns a number defining the aspect ratio
  36495. */
  36496. getScreenAspectRatio(): number;
  36497. /**
  36498. * Gets the client rect of the HTML canvas attached with the current webGL context
  36499. * @returns a client rectanglee
  36500. */
  36501. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36502. /**
  36503. * Gets the client rect of the HTML element used for events
  36504. * @returns a client rectanglee
  36505. */
  36506. getInputElementClientRect(): Nullable<ClientRect>;
  36507. /**
  36508. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36509. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36510. * @returns true if engine is in deterministic lock step mode
  36511. */
  36512. isDeterministicLockStep(): boolean;
  36513. /**
  36514. * Gets the max steps when engine is running in deterministic lock step
  36515. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36516. * @returns the max steps
  36517. */
  36518. getLockstepMaxSteps(): number;
  36519. /**
  36520. * Returns the time in ms between steps when using deterministic lock step.
  36521. * @returns time step in (ms)
  36522. */
  36523. getTimeStep(): number;
  36524. /**
  36525. * Force the mipmap generation for the given render target texture
  36526. * @param texture defines the render target texture to use
  36527. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36528. */
  36529. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36530. /** States */
  36531. /**
  36532. * Set various states to the webGL context
  36533. * @param culling defines backface culling state
  36534. * @param zOffset defines the value to apply to zOffset (0 by default)
  36535. * @param force defines if states must be applied even if cache is up to date
  36536. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36537. */
  36538. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36539. /**
  36540. * Set the z offset to apply to current rendering
  36541. * @param value defines the offset to apply
  36542. */
  36543. setZOffset(value: number): void;
  36544. /**
  36545. * Gets the current value of the zOffset
  36546. * @returns the current zOffset state
  36547. */
  36548. getZOffset(): number;
  36549. /**
  36550. * Enable or disable depth buffering
  36551. * @param enable defines the state to set
  36552. */
  36553. setDepthBuffer(enable: boolean): void;
  36554. /**
  36555. * Gets a boolean indicating if depth writing is enabled
  36556. * @returns the current depth writing state
  36557. */
  36558. getDepthWrite(): boolean;
  36559. /**
  36560. * Enable or disable depth writing
  36561. * @param enable defines the state to set
  36562. */
  36563. setDepthWrite(enable: boolean): void;
  36564. /**
  36565. * Gets a boolean indicating if stencil buffer is enabled
  36566. * @returns the current stencil buffer state
  36567. */
  36568. getStencilBuffer(): boolean;
  36569. /**
  36570. * Enable or disable the stencil buffer
  36571. * @param enable defines if the stencil buffer must be enabled or disabled
  36572. */
  36573. setStencilBuffer(enable: boolean): void;
  36574. /**
  36575. * Gets the current stencil mask
  36576. * @returns a number defining the new stencil mask to use
  36577. */
  36578. getStencilMask(): number;
  36579. /**
  36580. * Sets the current stencil mask
  36581. * @param mask defines the new stencil mask to use
  36582. */
  36583. setStencilMask(mask: number): void;
  36584. /**
  36585. * Gets the current stencil function
  36586. * @returns a number defining the stencil function to use
  36587. */
  36588. getStencilFunction(): number;
  36589. /**
  36590. * Gets the current stencil reference value
  36591. * @returns a number defining the stencil reference value to use
  36592. */
  36593. getStencilFunctionReference(): number;
  36594. /**
  36595. * Gets the current stencil mask
  36596. * @returns a number defining the stencil mask to use
  36597. */
  36598. getStencilFunctionMask(): number;
  36599. /**
  36600. * Sets the current stencil function
  36601. * @param stencilFunc defines the new stencil function to use
  36602. */
  36603. setStencilFunction(stencilFunc: number): void;
  36604. /**
  36605. * Sets the current stencil reference
  36606. * @param reference defines the new stencil reference to use
  36607. */
  36608. setStencilFunctionReference(reference: number): void;
  36609. /**
  36610. * Sets the current stencil mask
  36611. * @param mask defines the new stencil mask to use
  36612. */
  36613. setStencilFunctionMask(mask: number): void;
  36614. /**
  36615. * Gets the current stencil operation when stencil fails
  36616. * @returns a number defining stencil operation to use when stencil fails
  36617. */
  36618. getStencilOperationFail(): number;
  36619. /**
  36620. * Gets the current stencil operation when depth fails
  36621. * @returns a number defining stencil operation to use when depth fails
  36622. */
  36623. getStencilOperationDepthFail(): number;
  36624. /**
  36625. * Gets the current stencil operation when stencil passes
  36626. * @returns a number defining stencil operation to use when stencil passes
  36627. */
  36628. getStencilOperationPass(): number;
  36629. /**
  36630. * Sets the stencil operation to use when stencil fails
  36631. * @param operation defines the stencil operation to use when stencil fails
  36632. */
  36633. setStencilOperationFail(operation: number): void;
  36634. /**
  36635. * Sets the stencil operation to use when depth fails
  36636. * @param operation defines the stencil operation to use when depth fails
  36637. */
  36638. setStencilOperationDepthFail(operation: number): void;
  36639. /**
  36640. * Sets the stencil operation to use when stencil passes
  36641. * @param operation defines the stencil operation to use when stencil passes
  36642. */
  36643. setStencilOperationPass(operation: number): void;
  36644. /**
  36645. * Sets a boolean indicating if the dithering state is enabled or disabled
  36646. * @param value defines the dithering state
  36647. */
  36648. setDitheringState(value: boolean): void;
  36649. /**
  36650. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36651. * @param value defines the rasterizer state
  36652. */
  36653. setRasterizerState(value: boolean): void;
  36654. /**
  36655. * Gets the current depth function
  36656. * @returns a number defining the depth function
  36657. */
  36658. getDepthFunction(): Nullable<number>;
  36659. /**
  36660. * Sets the current depth function
  36661. * @param depthFunc defines the function to use
  36662. */
  36663. setDepthFunction(depthFunc: number): void;
  36664. /**
  36665. * Sets the current depth function to GREATER
  36666. */
  36667. setDepthFunctionToGreater(): void;
  36668. /**
  36669. * Sets the current depth function to GEQUAL
  36670. */
  36671. setDepthFunctionToGreaterOrEqual(): void;
  36672. /**
  36673. * Sets the current depth function to LESS
  36674. */
  36675. setDepthFunctionToLess(): void;
  36676. /**
  36677. * Sets the current depth function to LEQUAL
  36678. */
  36679. setDepthFunctionToLessOrEqual(): void;
  36680. private _cachedStencilBuffer;
  36681. private _cachedStencilFunction;
  36682. private _cachedStencilMask;
  36683. private _cachedStencilOperationPass;
  36684. private _cachedStencilOperationFail;
  36685. private _cachedStencilOperationDepthFail;
  36686. private _cachedStencilReference;
  36687. /**
  36688. * Caches the the state of the stencil buffer
  36689. */
  36690. cacheStencilState(): void;
  36691. /**
  36692. * Restores the state of the stencil buffer
  36693. */
  36694. restoreStencilState(): void;
  36695. /**
  36696. * Directly set the WebGL Viewport
  36697. * @param x defines the x coordinate of the viewport (in screen space)
  36698. * @param y defines the y coordinate of the viewport (in screen space)
  36699. * @param width defines the width of the viewport (in screen space)
  36700. * @param height defines the height of the viewport (in screen space)
  36701. * @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
  36702. */
  36703. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36704. /**
  36705. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36706. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36707. * @param y defines the y-coordinate of the corner of the clear rectangle
  36708. * @param width defines the width of the clear rectangle
  36709. * @param height defines the height of the clear rectangle
  36710. * @param clearColor defines the clear color
  36711. */
  36712. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36713. /**
  36714. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36715. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36716. * @param y defines the y-coordinate of the corner of the clear rectangle
  36717. * @param width defines the width of the clear rectangle
  36718. * @param height defines the height of the clear rectangle
  36719. */
  36720. enableScissor(x: number, y: number, width: number, height: number): void;
  36721. /**
  36722. * Disable previously set scissor test rectangle
  36723. */
  36724. disableScissor(): void;
  36725. protected _reportDrawCall(): void;
  36726. /**
  36727. * Initializes a webVR display and starts listening to display change events
  36728. * The onVRDisplayChangedObservable will be notified upon these changes
  36729. * @returns The onVRDisplayChangedObservable
  36730. */
  36731. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36732. /** @hidden */
  36733. _prepareVRComponent(): void;
  36734. /** @hidden */
  36735. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36736. /** @hidden */
  36737. _submitVRFrame(): void;
  36738. /**
  36739. * Call this function to leave webVR mode
  36740. * Will do nothing if webVR is not supported or if there is no webVR device
  36741. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36742. */
  36743. disableVR(): void;
  36744. /**
  36745. * Gets a boolean indicating that the system is in VR mode and is presenting
  36746. * @returns true if VR mode is engaged
  36747. */
  36748. isVRPresenting(): boolean;
  36749. /** @hidden */
  36750. _requestVRFrame(): void;
  36751. /** @hidden */
  36752. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36753. /**
  36754. * Gets the source code of the vertex shader associated with a specific webGL program
  36755. * @param program defines the program to use
  36756. * @returns a string containing the source code of the vertex shader associated with the program
  36757. */
  36758. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  36759. /**
  36760. * Gets the source code of the fragment shader associated with a specific webGL program
  36761. * @param program defines the program to use
  36762. * @returns a string containing the source code of the fragment shader associated with the program
  36763. */
  36764. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  36765. /**
  36766. * Sets a depth stencil texture from a render target to the according uniform.
  36767. * @param channel The texture channel
  36768. * @param uniform The uniform to set
  36769. * @param texture The render target texture containing the depth stencil texture to apply
  36770. */
  36771. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  36772. /**
  36773. * Sets a texture to the webGL context from a postprocess
  36774. * @param channel defines the channel to use
  36775. * @param postProcess defines the source postprocess
  36776. */
  36777. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  36778. /**
  36779. * Binds the output of the passed in post process to the texture channel specified
  36780. * @param channel The channel the texture should be bound to
  36781. * @param postProcess The post process which's output should be bound
  36782. */
  36783. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  36784. protected _rebuildBuffers(): void;
  36785. /** @hidden */
  36786. _renderFrame(): void;
  36787. _renderLoop(): void;
  36788. /** @hidden */
  36789. _renderViews(): boolean;
  36790. /**
  36791. * Toggle full screen mode
  36792. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36793. */
  36794. switchFullscreen(requestPointerLock: boolean): void;
  36795. /**
  36796. * Enters full screen mode
  36797. * @param requestPointerLock defines if a pointer lock should be requested from the user
  36798. */
  36799. enterFullscreen(requestPointerLock: boolean): void;
  36800. /**
  36801. * Exits full screen mode
  36802. */
  36803. exitFullscreen(): void;
  36804. /**
  36805. * Enters Pointerlock mode
  36806. */
  36807. enterPointerlock(): void;
  36808. /**
  36809. * Exits Pointerlock mode
  36810. */
  36811. exitPointerlock(): void;
  36812. /**
  36813. * Begin a new frame
  36814. */
  36815. beginFrame(): void;
  36816. /**
  36817. * Enf the current frame
  36818. */
  36819. endFrame(): void;
  36820. resize(): void;
  36821. /**
  36822. * Force a specific size of the canvas
  36823. * @param width defines the new canvas' width
  36824. * @param height defines the new canvas' height
  36825. */
  36826. setSize(width: number, height: number): void;
  36827. /**
  36828. * Updates a dynamic vertex buffer.
  36829. * @param vertexBuffer the vertex buffer to update
  36830. * @param data the data used to update the vertex buffer
  36831. * @param byteOffset the byte offset of the data
  36832. * @param byteLength the byte length of the data
  36833. */
  36834. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  36835. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36836. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36837. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36838. _releaseTexture(texture: InternalTexture): void;
  36839. /**
  36840. * @hidden
  36841. * Rescales a texture
  36842. * @param source input texutre
  36843. * @param destination destination texture
  36844. * @param scene scene to use to render the resize
  36845. * @param internalFormat format to use when resizing
  36846. * @param onComplete callback to be called when resize has completed
  36847. */
  36848. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36849. /**
  36850. * Gets the current framerate
  36851. * @returns a number representing the framerate
  36852. */
  36853. getFps(): number;
  36854. /**
  36855. * Gets the time spent between current and previous frame
  36856. * @returns a number representing the delta time in ms
  36857. */
  36858. getDeltaTime(): number;
  36859. private _measureFps;
  36860. /** @hidden */
  36861. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  36862. /**
  36863. * Update a dynamic index buffer
  36864. * @param indexBuffer defines the target index buffer
  36865. * @param indices defines the data to update
  36866. * @param offset defines the offset in the target index buffer where update should start
  36867. */
  36868. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  36869. /**
  36870. * Updates the sample count of a render target texture
  36871. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  36872. * @param texture defines the texture to update
  36873. * @param samples defines the sample count to set
  36874. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  36875. */
  36876. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  36877. /**
  36878. * Updates a depth texture Comparison Mode and Function.
  36879. * If the comparison Function is equal to 0, the mode will be set to none.
  36880. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  36881. * @param texture The texture to set the comparison function for
  36882. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  36883. */
  36884. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  36885. /**
  36886. * Creates a webGL buffer to use with instanciation
  36887. * @param capacity defines the size of the buffer
  36888. * @returns the webGL buffer
  36889. */
  36890. createInstancesBuffer(capacity: number): DataBuffer;
  36891. /**
  36892. * Delete a webGL buffer used with instanciation
  36893. * @param buffer defines the webGL buffer to delete
  36894. */
  36895. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  36896. private _clientWaitAsync;
  36897. /** @hidden */
  36898. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  36899. dispose(): void;
  36900. private _disableTouchAction;
  36901. /**
  36902. * Display the loading screen
  36903. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36904. */
  36905. displayLoadingUI(): void;
  36906. /**
  36907. * Hide the loading screen
  36908. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36909. */
  36910. hideLoadingUI(): void;
  36911. /**
  36912. * Gets the current loading screen object
  36913. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36914. */
  36915. get loadingScreen(): ILoadingScreen;
  36916. /**
  36917. * Sets the current loading screen object
  36918. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36919. */
  36920. set loadingScreen(loadingScreen: ILoadingScreen);
  36921. /**
  36922. * Sets the current loading screen text
  36923. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36924. */
  36925. set loadingUIText(text: string);
  36926. /**
  36927. * Sets the current loading screen background color
  36928. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36929. */
  36930. set loadingUIBackgroundColor(color: string);
  36931. /** Pointerlock and fullscreen */
  36932. /**
  36933. * Ask the browser to promote the current element to pointerlock mode
  36934. * @param element defines the DOM element to promote
  36935. */
  36936. static _RequestPointerlock(element: HTMLElement): void;
  36937. /**
  36938. * Asks the browser to exit pointerlock mode
  36939. */
  36940. static _ExitPointerlock(): void;
  36941. /**
  36942. * Ask the browser to promote the current element to fullscreen rendering mode
  36943. * @param element defines the DOM element to promote
  36944. */
  36945. static _RequestFullscreen(element: HTMLElement): void;
  36946. /**
  36947. * Asks the browser to exit fullscreen mode
  36948. */
  36949. static _ExitFullscreen(): void;
  36950. }
  36951. }
  36952. declare module BABYLON {
  36953. /**
  36954. * The engine store class is responsible to hold all the instances of Engine and Scene created
  36955. * during the life time of the application.
  36956. */
  36957. export class EngineStore {
  36958. /** Gets the list of created engines */
  36959. static Instances: Engine[];
  36960. /** @hidden */
  36961. static _LastCreatedScene: Nullable<Scene>;
  36962. /**
  36963. * Gets the latest created engine
  36964. */
  36965. static get LastCreatedEngine(): Nullable<Engine>;
  36966. /**
  36967. * Gets the latest created scene
  36968. */
  36969. static get LastCreatedScene(): Nullable<Scene>;
  36970. /**
  36971. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  36972. * @ignorenaming
  36973. */
  36974. static UseFallbackTexture: boolean;
  36975. /**
  36976. * Texture content used if a texture cannot loaded
  36977. * @ignorenaming
  36978. */
  36979. static FallbackTexture: string;
  36980. }
  36981. }
  36982. declare module BABYLON {
  36983. /**
  36984. * Helper class that provides a small promise polyfill
  36985. */
  36986. export class PromisePolyfill {
  36987. /**
  36988. * Static function used to check if the polyfill is required
  36989. * If this is the case then the function will inject the polyfill to window.Promise
  36990. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  36991. */
  36992. static Apply(force?: boolean): void;
  36993. }
  36994. }
  36995. declare module BABYLON {
  36996. /**
  36997. * Interface for screenshot methods with describe argument called `size` as object with options
  36998. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  36999. */
  37000. export interface IScreenshotSize {
  37001. /**
  37002. * number in pixels for canvas height
  37003. */
  37004. height?: number;
  37005. /**
  37006. * multiplier allowing render at a higher or lower resolution
  37007. * If value is defined then height and width will be ignored and taken from camera
  37008. */
  37009. precision?: number;
  37010. /**
  37011. * number in pixels for canvas width
  37012. */
  37013. width?: number;
  37014. }
  37015. }
  37016. declare module BABYLON {
  37017. interface IColor4Like {
  37018. r: float;
  37019. g: float;
  37020. b: float;
  37021. a: float;
  37022. }
  37023. /**
  37024. * Class containing a set of static utilities functions
  37025. */
  37026. export class Tools {
  37027. /**
  37028. * Gets or sets the base URL to use to load assets
  37029. */
  37030. static get BaseUrl(): string;
  37031. static set BaseUrl(value: string);
  37032. /**
  37033. * Enable/Disable Custom HTTP Request Headers globally.
  37034. * default = false
  37035. * @see CustomRequestHeaders
  37036. */
  37037. static UseCustomRequestHeaders: boolean;
  37038. /**
  37039. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37040. * i.e. when loading files, where the server/service expects an Authorization header
  37041. */
  37042. static CustomRequestHeaders: {
  37043. [key: string]: string;
  37044. };
  37045. /**
  37046. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37047. */
  37048. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37049. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37050. /**
  37051. * Default behaviour for cors in the application.
  37052. * It can be a string if the expected behavior is identical in the entire app.
  37053. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37054. */
  37055. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37056. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37057. /**
  37058. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37059. * @ignorenaming
  37060. */
  37061. static get UseFallbackTexture(): boolean;
  37062. static set UseFallbackTexture(value: boolean);
  37063. /**
  37064. * Use this object to register external classes like custom textures or material
  37065. * to allow the laoders to instantiate them
  37066. */
  37067. static get RegisteredExternalClasses(): {
  37068. [key: string]: Object;
  37069. };
  37070. static set RegisteredExternalClasses(classes: {
  37071. [key: string]: Object;
  37072. });
  37073. /**
  37074. * Texture content used if a texture cannot loaded
  37075. * @ignorenaming
  37076. */
  37077. static get fallbackTexture(): string;
  37078. static set fallbackTexture(value: string);
  37079. /**
  37080. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37081. * @param u defines the coordinate on X axis
  37082. * @param v defines the coordinate on Y axis
  37083. * @param width defines the width of the source data
  37084. * @param height defines the height of the source data
  37085. * @param pixels defines the source byte array
  37086. * @param color defines the output color
  37087. */
  37088. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37089. /**
  37090. * Interpolates between a and b via alpha
  37091. * @param a The lower value (returned when alpha = 0)
  37092. * @param b The upper value (returned when alpha = 1)
  37093. * @param alpha The interpolation-factor
  37094. * @return The mixed value
  37095. */
  37096. static Mix(a: number, b: number, alpha: number): number;
  37097. /**
  37098. * Tries to instantiate a new object from a given class name
  37099. * @param className defines the class name to instantiate
  37100. * @returns the new object or null if the system was not able to do the instantiation
  37101. */
  37102. static Instantiate(className: string): any;
  37103. /**
  37104. * Provides a slice function that will work even on IE
  37105. * @param data defines the array to slice
  37106. * @param start defines the start of the data (optional)
  37107. * @param end defines the end of the data (optional)
  37108. * @returns the new sliced array
  37109. */
  37110. static Slice<T>(data: T, start?: number, end?: number): T;
  37111. /**
  37112. * Polyfill for setImmediate
  37113. * @param action defines the action to execute after the current execution block
  37114. */
  37115. static SetImmediate(action: () => void): void;
  37116. /**
  37117. * Function indicating if a number is an exponent of 2
  37118. * @param value defines the value to test
  37119. * @returns true if the value is an exponent of 2
  37120. */
  37121. static IsExponentOfTwo(value: number): boolean;
  37122. private static _tmpFloatArray;
  37123. /**
  37124. * Returns the nearest 32-bit single precision float representation of a Number
  37125. * @param value A Number. If the parameter is of a different type, it will get converted
  37126. * to a number or to NaN if it cannot be converted
  37127. * @returns number
  37128. */
  37129. static FloatRound(value: number): number;
  37130. /**
  37131. * Extracts the filename from a path
  37132. * @param path defines the path to use
  37133. * @returns the filename
  37134. */
  37135. static GetFilename(path: string): string;
  37136. /**
  37137. * Extracts the "folder" part of a path (everything before the filename).
  37138. * @param uri The URI to extract the info from
  37139. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37140. * @returns The "folder" part of the path
  37141. */
  37142. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37143. /**
  37144. * Extracts text content from a DOM element hierarchy
  37145. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37146. */
  37147. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37148. /**
  37149. * Convert an angle in radians to degrees
  37150. * @param angle defines the angle to convert
  37151. * @returns the angle in degrees
  37152. */
  37153. static ToDegrees(angle: number): number;
  37154. /**
  37155. * Convert an angle in degrees to radians
  37156. * @param angle defines the angle to convert
  37157. * @returns the angle in radians
  37158. */
  37159. static ToRadians(angle: number): number;
  37160. /**
  37161. * Returns an array if obj is not an array
  37162. * @param obj defines the object to evaluate as an array
  37163. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37164. * @returns either obj directly if obj is an array or a new array containing obj
  37165. */
  37166. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37167. /**
  37168. * Gets the pointer prefix to use
  37169. * @param engine defines the engine we are finding the prefix for
  37170. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37171. */
  37172. static GetPointerPrefix(engine: Engine): string;
  37173. /**
  37174. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37175. * @param url define the url we are trying
  37176. * @param element define the dom element where to configure the cors policy
  37177. */
  37178. static SetCorsBehavior(url: string | string[], element: {
  37179. crossOrigin: string | null;
  37180. }): void;
  37181. /**
  37182. * Removes unwanted characters from an url
  37183. * @param url defines the url to clean
  37184. * @returns the cleaned url
  37185. */
  37186. static CleanUrl(url: string): string;
  37187. /**
  37188. * Gets or sets a function used to pre-process url before using them to load assets
  37189. */
  37190. static get PreprocessUrl(): (url: string) => string;
  37191. static set PreprocessUrl(processor: (url: string) => string);
  37192. /**
  37193. * Loads an image as an HTMLImageElement.
  37194. * @param input url string, ArrayBuffer, or Blob to load
  37195. * @param onLoad callback called when the image successfully loads
  37196. * @param onError callback called when the image fails to load
  37197. * @param offlineProvider offline provider for caching
  37198. * @param mimeType optional mime type
  37199. * @returns the HTMLImageElement of the loaded image
  37200. */
  37201. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37202. /**
  37203. * Loads a file from a url
  37204. * @param url url string, ArrayBuffer, or Blob to load
  37205. * @param onSuccess callback called when the file successfully loads
  37206. * @param onProgress callback called while file is loading (if the server supports this mode)
  37207. * @param offlineProvider defines the offline provider for caching
  37208. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37209. * @param onError callback called when the file fails to load
  37210. * @returns a file request object
  37211. */
  37212. 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;
  37213. /**
  37214. * Loads a file from a url
  37215. * @param url the file url to load
  37216. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37217. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37218. */
  37219. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37220. /**
  37221. * Load a script (identified by an url). When the url returns, the
  37222. * content of this file is added into a new script element, attached to the DOM (body element)
  37223. * @param scriptUrl defines the url of the script to laod
  37224. * @param onSuccess defines the callback called when the script is loaded
  37225. * @param onError defines the callback to call if an error occurs
  37226. * @param scriptId defines the id of the script element
  37227. */
  37228. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37229. /**
  37230. * Load an asynchronous script (identified by an url). When the url returns, the
  37231. * content of this file is added into a new script element, attached to the DOM (body element)
  37232. * @param scriptUrl defines the url of the script to laod
  37233. * @param scriptId defines the id of the script element
  37234. * @returns a promise request object
  37235. */
  37236. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37237. /**
  37238. * Loads a file from a blob
  37239. * @param fileToLoad defines the blob to use
  37240. * @param callback defines the callback to call when data is loaded
  37241. * @param progressCallback defines the callback to call during loading process
  37242. * @returns a file request object
  37243. */
  37244. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37245. /**
  37246. * Reads a file from a File object
  37247. * @param file defines the file to load
  37248. * @param onSuccess defines the callback to call when data is loaded
  37249. * @param onProgress defines the callback to call during loading process
  37250. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37251. * @param onError defines the callback to call when an error occurs
  37252. * @returns a file request object
  37253. */
  37254. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37255. /**
  37256. * Creates a data url from a given string content
  37257. * @param content defines the content to convert
  37258. * @returns the new data url link
  37259. */
  37260. static FileAsURL(content: string): string;
  37261. /**
  37262. * Format the given number to a specific decimal format
  37263. * @param value defines the number to format
  37264. * @param decimals defines the number of decimals to use
  37265. * @returns the formatted string
  37266. */
  37267. static Format(value: number, decimals?: number): string;
  37268. /**
  37269. * Tries to copy an object by duplicating every property
  37270. * @param source defines the source object
  37271. * @param destination defines the target object
  37272. * @param doNotCopyList defines a list of properties to avoid
  37273. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37274. */
  37275. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37276. /**
  37277. * Gets a boolean indicating if the given object has no own property
  37278. * @param obj defines the object to test
  37279. * @returns true if object has no own property
  37280. */
  37281. static IsEmpty(obj: any): boolean;
  37282. /**
  37283. * Function used to register events at window level
  37284. * @param windowElement defines the Window object to use
  37285. * @param events defines the events to register
  37286. */
  37287. static RegisterTopRootEvents(windowElement: Window, events: {
  37288. name: string;
  37289. handler: Nullable<(e: FocusEvent) => any>;
  37290. }[]): void;
  37291. /**
  37292. * Function used to unregister events from window level
  37293. * @param windowElement defines the Window object to use
  37294. * @param events defines the events to unregister
  37295. */
  37296. static UnregisterTopRootEvents(windowElement: Window, events: {
  37297. name: string;
  37298. handler: Nullable<(e: FocusEvent) => any>;
  37299. }[]): void;
  37300. /**
  37301. * @ignore
  37302. */
  37303. static _ScreenshotCanvas: HTMLCanvasElement;
  37304. /**
  37305. * Dumps the current bound framebuffer
  37306. * @param width defines the rendering width
  37307. * @param height defines the rendering height
  37308. * @param engine defines the hosting engine
  37309. * @param successCallback defines the callback triggered once the data are available
  37310. * @param mimeType defines the mime type of the result
  37311. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37312. */
  37313. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37314. /**
  37315. * Converts the canvas data to blob.
  37316. * This acts as a polyfill for browsers not supporting the to blob function.
  37317. * @param canvas Defines the canvas to extract the data from
  37318. * @param successCallback Defines the callback triggered once the data are available
  37319. * @param mimeType Defines the mime type of the result
  37320. */
  37321. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37322. /**
  37323. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37324. * @param successCallback defines the callback triggered once the data are available
  37325. * @param mimeType defines the mime type of the result
  37326. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37327. */
  37328. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37329. /**
  37330. * Downloads a blob in the browser
  37331. * @param blob defines the blob to download
  37332. * @param fileName defines the name of the downloaded file
  37333. */
  37334. static Download(blob: Blob, fileName: string): void;
  37335. /**
  37336. * Captures a screenshot of the current rendering
  37337. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37338. * @param engine defines the rendering engine
  37339. * @param camera defines the source camera
  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 successCallback defines the callback receives a single parameter which contains the
  37346. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37347. * src parameter of an <img> to display it
  37348. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37349. * Check your browser for supported MIME types
  37350. */
  37351. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37352. /**
  37353. * Captures a screenshot of the current rendering
  37354. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37355. * @param engine defines the rendering engine
  37356. * @param camera defines the source camera
  37357. * @param size This parameter can be set to a single number or to an object with the
  37358. * following (optional) properties: precision, width, height. If a single number is passed,
  37359. * it will be used for both width and height. If an object is passed, the screenshot size
  37360. * will be derived from the parameters. The precision property is a multiplier allowing
  37361. * rendering at a higher or lower resolution
  37362. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37363. * Check your browser for supported MIME types
  37364. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37365. * to the src parameter of an <img> to display it
  37366. */
  37367. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37368. /**
  37369. * Generates an image screenshot from the specified camera.
  37370. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37371. * @param engine The engine to use for rendering
  37372. * @param camera The camera to use for rendering
  37373. * @param size This parameter can be set to a single number or to an object with the
  37374. * following (optional) properties: precision, width, height. If a single number is passed,
  37375. * it will be used for both width and height. If an object is passed, the screenshot size
  37376. * will be derived from the parameters. The precision property is a multiplier allowing
  37377. * rendering at a higher or lower resolution
  37378. * @param successCallback The callback receives a single parameter which contains the
  37379. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37380. * src parameter of an <img> to display it
  37381. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37382. * Check your browser for supported MIME types
  37383. * @param samples Texture samples (default: 1)
  37384. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37385. * @param fileName A name for for the downloaded file.
  37386. */
  37387. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37388. /**
  37389. * Generates an image screenshot from the specified camera.
  37390. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37391. * @param engine The engine to use for rendering
  37392. * @param camera The camera to use for rendering
  37393. * @param size This parameter can be set to a single number or to an object with the
  37394. * following (optional) properties: precision, width, height. If a single number is passed,
  37395. * it will be used for both width and height. If an object is passed, the screenshot size
  37396. * will be derived from the parameters. The precision property is a multiplier allowing
  37397. * rendering at a higher or lower resolution
  37398. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37399. * Check your browser for supported MIME types
  37400. * @param samples Texture samples (default: 1)
  37401. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37402. * @param fileName A name for for the downloaded file.
  37403. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37404. * to the src parameter of an <img> to display it
  37405. */
  37406. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37407. /**
  37408. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37409. * Be aware Math.random() could cause collisions, but:
  37410. * "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"
  37411. * @returns a pseudo random id
  37412. */
  37413. static RandomId(): string;
  37414. /**
  37415. * Test if the given uri is a base64 string
  37416. * @param uri The uri to test
  37417. * @return True if the uri is a base64 string or false otherwise
  37418. */
  37419. static IsBase64(uri: string): boolean;
  37420. /**
  37421. * Decode the given base64 uri.
  37422. * @param uri The uri to decode
  37423. * @return The decoded base64 data.
  37424. */
  37425. static DecodeBase64(uri: string): ArrayBuffer;
  37426. /**
  37427. * Gets the absolute url.
  37428. * @param url the input url
  37429. * @return the absolute url
  37430. */
  37431. static GetAbsoluteUrl(url: string): string;
  37432. /**
  37433. * No log
  37434. */
  37435. static readonly NoneLogLevel: number;
  37436. /**
  37437. * Only message logs
  37438. */
  37439. static readonly MessageLogLevel: number;
  37440. /**
  37441. * Only warning logs
  37442. */
  37443. static readonly WarningLogLevel: number;
  37444. /**
  37445. * Only error logs
  37446. */
  37447. static readonly ErrorLogLevel: number;
  37448. /**
  37449. * All logs
  37450. */
  37451. static readonly AllLogLevel: number;
  37452. /**
  37453. * Gets a value indicating the number of loading errors
  37454. * @ignorenaming
  37455. */
  37456. static get errorsCount(): number;
  37457. /**
  37458. * Callback called when a new log is added
  37459. */
  37460. static OnNewCacheEntry: (entry: string) => void;
  37461. /**
  37462. * Log a message to the console
  37463. * @param message defines the message to log
  37464. */
  37465. static Log(message: string): void;
  37466. /**
  37467. * Write a warning message to the console
  37468. * @param message defines the message to log
  37469. */
  37470. static Warn(message: string): void;
  37471. /**
  37472. * Write an error message to the console
  37473. * @param message defines the message to log
  37474. */
  37475. static Error(message: string): void;
  37476. /**
  37477. * Gets current log cache (list of logs)
  37478. */
  37479. static get LogCache(): string;
  37480. /**
  37481. * Clears the log cache
  37482. */
  37483. static ClearLogCache(): void;
  37484. /**
  37485. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37486. */
  37487. static set LogLevels(level: number);
  37488. /**
  37489. * Checks if the window object exists
  37490. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37491. */
  37492. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37493. /**
  37494. * No performance log
  37495. */
  37496. static readonly PerformanceNoneLogLevel: number;
  37497. /**
  37498. * Use user marks to log performance
  37499. */
  37500. static readonly PerformanceUserMarkLogLevel: number;
  37501. /**
  37502. * Log performance to the console
  37503. */
  37504. static readonly PerformanceConsoleLogLevel: number;
  37505. private static _performance;
  37506. /**
  37507. * Sets the current performance log level
  37508. */
  37509. static set PerformanceLogLevel(level: number);
  37510. private static _StartPerformanceCounterDisabled;
  37511. private static _EndPerformanceCounterDisabled;
  37512. private static _StartUserMark;
  37513. private static _EndUserMark;
  37514. private static _StartPerformanceConsole;
  37515. private static _EndPerformanceConsole;
  37516. /**
  37517. * Starts a performance counter
  37518. */
  37519. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37520. /**
  37521. * Ends a specific performance coutner
  37522. */
  37523. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37524. /**
  37525. * Gets either window.performance.now() if supported or Date.now() else
  37526. */
  37527. static get Now(): number;
  37528. /**
  37529. * This method will return the name of the class used to create the instance of the given object.
  37530. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37531. * @param object the object to get the class name from
  37532. * @param isType defines if the object is actually a type
  37533. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37534. */
  37535. static GetClassName(object: any, isType?: boolean): string;
  37536. /**
  37537. * Gets the first element of an array satisfying a given predicate
  37538. * @param array defines the array to browse
  37539. * @param predicate defines the predicate to use
  37540. * @returns null if not found or the element
  37541. */
  37542. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37543. /**
  37544. * This method will return the name of the full name of the class, including its owning module (if any).
  37545. * 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).
  37546. * @param object the object to get the class name from
  37547. * @param isType defines if the object is actually a type
  37548. * @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.
  37549. * @ignorenaming
  37550. */
  37551. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37552. /**
  37553. * Returns a promise that resolves after the given amount of time.
  37554. * @param delay Number of milliseconds to delay
  37555. * @returns Promise that resolves after the given amount of time
  37556. */
  37557. static DelayAsync(delay: number): Promise<void>;
  37558. /**
  37559. * Utility function to detect if the current user agent is Safari
  37560. * @returns whether or not the current user agent is safari
  37561. */
  37562. static IsSafari(): boolean;
  37563. }
  37564. /**
  37565. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37566. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37567. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37568. * @param name The name of the class, case should be preserved
  37569. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37570. */
  37571. export function className(name: string, module?: string): (target: Object) => void;
  37572. /**
  37573. * An implementation of a loop for asynchronous functions.
  37574. */
  37575. export class AsyncLoop {
  37576. /**
  37577. * Defines the number of iterations for the loop
  37578. */
  37579. iterations: number;
  37580. /**
  37581. * Defines the current index of the loop.
  37582. */
  37583. index: number;
  37584. private _done;
  37585. private _fn;
  37586. private _successCallback;
  37587. /**
  37588. * Constructor.
  37589. * @param iterations the number of iterations.
  37590. * @param func the function to run each iteration
  37591. * @param successCallback the callback that will be called upon succesful execution
  37592. * @param offset starting offset.
  37593. */
  37594. constructor(
  37595. /**
  37596. * Defines the number of iterations for the loop
  37597. */
  37598. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37599. /**
  37600. * Execute the next iteration. Must be called after the last iteration was finished.
  37601. */
  37602. executeNext(): void;
  37603. /**
  37604. * Break the loop and run the success callback.
  37605. */
  37606. breakLoop(): void;
  37607. /**
  37608. * Create and run an async loop.
  37609. * @param iterations the number of iterations.
  37610. * @param fn the function to run each iteration
  37611. * @param successCallback the callback that will be called upon succesful execution
  37612. * @param offset starting offset.
  37613. * @returns the created async loop object
  37614. */
  37615. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37616. /**
  37617. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37618. * @param iterations total number of iterations
  37619. * @param syncedIterations number of synchronous iterations in each async iteration.
  37620. * @param fn the function to call each iteration.
  37621. * @param callback a success call back that will be called when iterating stops.
  37622. * @param breakFunction a break condition (optional)
  37623. * @param timeout timeout settings for the setTimeout function. default - 0.
  37624. * @returns the created async loop object
  37625. */
  37626. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37627. }
  37628. }
  37629. declare module BABYLON {
  37630. /**
  37631. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37632. * The underlying implementation relies on an associative array to ensure the best performances.
  37633. * The value can be anything including 'null' but except 'undefined'
  37634. */
  37635. export class StringDictionary<T> {
  37636. /**
  37637. * This will clear this dictionary and copy the content from the 'source' one.
  37638. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37639. * @param source the dictionary to take the content from and copy to this dictionary
  37640. */
  37641. copyFrom(source: StringDictionary<T>): void;
  37642. /**
  37643. * Get a value based from its key
  37644. * @param key the given key to get the matching value from
  37645. * @return the value if found, otherwise undefined is returned
  37646. */
  37647. get(key: string): T | undefined;
  37648. /**
  37649. * Get a value from its key or add it if it doesn't exist.
  37650. * This method will ensure you that a given key/data will be present in the dictionary.
  37651. * @param key the given key to get the matching value from
  37652. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37653. * The factory will only be invoked if there's no data for the given key.
  37654. * @return the value corresponding to the key.
  37655. */
  37656. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37657. /**
  37658. * Get a value from its key if present in the dictionary otherwise add it
  37659. * @param key the key to get the value from
  37660. * @param val if there's no such key/value pair in the dictionary add it with this value
  37661. * @return the value corresponding to the key
  37662. */
  37663. getOrAdd(key: string, val: T): T;
  37664. /**
  37665. * Check if there's a given key in the dictionary
  37666. * @param key the key to check for
  37667. * @return true if the key is present, false otherwise
  37668. */
  37669. contains(key: string): boolean;
  37670. /**
  37671. * Add a new key and its corresponding value
  37672. * @param key the key to add
  37673. * @param value the value corresponding to the key
  37674. * @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
  37675. */
  37676. add(key: string, value: T): boolean;
  37677. /**
  37678. * Update a specific value associated to a key
  37679. * @param key defines the key to use
  37680. * @param value defines the value to store
  37681. * @returns true if the value was updated (or false if the key was not found)
  37682. */
  37683. set(key: string, value: T): boolean;
  37684. /**
  37685. * Get the element of the given key and remove it from the dictionary
  37686. * @param key defines the key to search
  37687. * @returns the value associated with the key or null if not found
  37688. */
  37689. getAndRemove(key: string): Nullable<T>;
  37690. /**
  37691. * Remove a key/value from the dictionary.
  37692. * @param key the key to remove
  37693. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37694. */
  37695. remove(key: string): boolean;
  37696. /**
  37697. * Clear the whole content of the dictionary
  37698. */
  37699. clear(): void;
  37700. /**
  37701. * Gets the current count
  37702. */
  37703. get count(): number;
  37704. /**
  37705. * Execute a callback on each key/val of the dictionary.
  37706. * Note that you can remove any element in this dictionary in the callback implementation
  37707. * @param callback the callback to execute on a given key/value pair
  37708. */
  37709. forEach(callback: (key: string, val: T) => void): void;
  37710. /**
  37711. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37712. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37713. * Note that you can remove any element in this dictionary in the callback implementation
  37714. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37715. * @returns the first item
  37716. */
  37717. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37718. private _count;
  37719. private _data;
  37720. }
  37721. }
  37722. declare module BABYLON {
  37723. /** @hidden */
  37724. export interface ICollisionCoordinator {
  37725. createCollider(): Collider;
  37726. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37727. init(scene: Scene): void;
  37728. }
  37729. /** @hidden */
  37730. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37731. private _scene;
  37732. private _scaledPosition;
  37733. private _scaledVelocity;
  37734. private _finalPosition;
  37735. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37736. createCollider(): Collider;
  37737. init(scene: Scene): void;
  37738. private _collideWithWorld;
  37739. }
  37740. }
  37741. declare module BABYLON {
  37742. /**
  37743. * Class used to manage all inputs for the scene.
  37744. */
  37745. export class InputManager {
  37746. /** The distance in pixel that you have to move to prevent some events */
  37747. static DragMovementThreshold: number;
  37748. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37749. static LongPressDelay: number;
  37750. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37751. static DoubleClickDelay: number;
  37752. /** If you need to check double click without raising a single click at first click, enable this flag */
  37753. static ExclusiveDoubleClickMode: boolean;
  37754. private _wheelEventName;
  37755. private _onPointerMove;
  37756. private _onPointerDown;
  37757. private _onPointerUp;
  37758. private _initClickEvent;
  37759. private _initActionManager;
  37760. private _delayedSimpleClick;
  37761. private _delayedSimpleClickTimeout;
  37762. private _previousDelayedSimpleClickTimeout;
  37763. private _meshPickProceed;
  37764. private _previousButtonPressed;
  37765. private _currentPickResult;
  37766. private _previousPickResult;
  37767. private _totalPointersPressed;
  37768. private _doubleClickOccured;
  37769. private _pointerOverMesh;
  37770. private _pickedDownMesh;
  37771. private _pickedUpMesh;
  37772. private _pointerX;
  37773. private _pointerY;
  37774. private _unTranslatedPointerX;
  37775. private _unTranslatedPointerY;
  37776. private _startingPointerPosition;
  37777. private _previousStartingPointerPosition;
  37778. private _startingPointerTime;
  37779. private _previousStartingPointerTime;
  37780. private _pointerCaptures;
  37781. private _onKeyDown;
  37782. private _onKeyUp;
  37783. private _onCanvasFocusObserver;
  37784. private _onCanvasBlurObserver;
  37785. private _scene;
  37786. /**
  37787. * Creates a new InputManager
  37788. * @param scene defines the hosting scene
  37789. */
  37790. constructor(scene: Scene);
  37791. /**
  37792. * Gets the mesh that is currently under the pointer
  37793. */
  37794. get meshUnderPointer(): Nullable<AbstractMesh>;
  37795. /**
  37796. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  37797. */
  37798. get unTranslatedPointer(): Vector2;
  37799. /**
  37800. * Gets or sets the current on-screen X position of the pointer
  37801. */
  37802. get pointerX(): number;
  37803. set pointerX(value: number);
  37804. /**
  37805. * Gets or sets the current on-screen Y position of the pointer
  37806. */
  37807. get pointerY(): number;
  37808. set pointerY(value: number);
  37809. private _updatePointerPosition;
  37810. private _processPointerMove;
  37811. private _setRayOnPointerInfo;
  37812. private _checkPrePointerObservable;
  37813. /**
  37814. * Use this method to simulate a pointer move on a mesh
  37815. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37816. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37817. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37818. */
  37819. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37820. /**
  37821. * Use this method to simulate a pointer down on a mesh
  37822. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37823. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37824. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37825. */
  37826. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  37827. private _processPointerDown;
  37828. /** @hidden */
  37829. _isPointerSwiping(): boolean;
  37830. /**
  37831. * Use this method to simulate a pointer up on a mesh
  37832. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37833. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37834. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37835. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37836. */
  37837. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  37838. private _processPointerUp;
  37839. /**
  37840. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37841. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37842. * @returns true if the pointer was captured
  37843. */
  37844. isPointerCaptured(pointerId?: number): boolean;
  37845. /**
  37846. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37847. * @param attachUp defines if you want to attach events to pointerup
  37848. * @param attachDown defines if you want to attach events to pointerdown
  37849. * @param attachMove defines if you want to attach events to pointermove
  37850. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  37851. */
  37852. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  37853. /**
  37854. * Detaches all event handlers
  37855. */
  37856. detachControl(): void;
  37857. /**
  37858. * Force the value of meshUnderPointer
  37859. * @param mesh defines the mesh to use
  37860. */
  37861. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37862. /**
  37863. * Gets the mesh under the pointer
  37864. * @returns a Mesh or null if no mesh is under the pointer
  37865. */
  37866. getPointerOverMesh(): Nullable<AbstractMesh>;
  37867. }
  37868. }
  37869. declare module BABYLON {
  37870. /**
  37871. * This class defines the direct association between an animation and a target
  37872. */
  37873. export class TargetedAnimation {
  37874. /**
  37875. * Animation to perform
  37876. */
  37877. animation: Animation;
  37878. /**
  37879. * Target to animate
  37880. */
  37881. target: any;
  37882. /**
  37883. * Serialize the object
  37884. * @returns the JSON object representing the current entity
  37885. */
  37886. serialize(): any;
  37887. }
  37888. /**
  37889. * Use this class to create coordinated animations on multiple targets
  37890. */
  37891. export class AnimationGroup implements IDisposable {
  37892. /** The name of the animation group */
  37893. name: string;
  37894. private _scene;
  37895. private _targetedAnimations;
  37896. private _animatables;
  37897. private _from;
  37898. private _to;
  37899. private _isStarted;
  37900. private _isPaused;
  37901. private _speedRatio;
  37902. private _loopAnimation;
  37903. private _isAdditive;
  37904. /**
  37905. * Gets or sets the unique id of the node
  37906. */
  37907. uniqueId: number;
  37908. /**
  37909. * This observable will notify when one animation have ended
  37910. */
  37911. onAnimationEndObservable: Observable<TargetedAnimation>;
  37912. /**
  37913. * Observer raised when one animation loops
  37914. */
  37915. onAnimationLoopObservable: Observable<TargetedAnimation>;
  37916. /**
  37917. * Observer raised when all animations have looped
  37918. */
  37919. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  37920. /**
  37921. * This observable will notify when all animations have ended.
  37922. */
  37923. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  37924. /**
  37925. * This observable will notify when all animations have paused.
  37926. */
  37927. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  37928. /**
  37929. * This observable will notify when all animations are playing.
  37930. */
  37931. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  37932. /**
  37933. * Gets the first frame
  37934. */
  37935. get from(): number;
  37936. /**
  37937. * Gets the last frame
  37938. */
  37939. get to(): number;
  37940. /**
  37941. * Define if the animations are started
  37942. */
  37943. get isStarted(): boolean;
  37944. /**
  37945. * Gets a value indicating that the current group is playing
  37946. */
  37947. get isPlaying(): boolean;
  37948. /**
  37949. * Gets or sets the speed ratio to use for all animations
  37950. */
  37951. get speedRatio(): number;
  37952. /**
  37953. * Gets or sets the speed ratio to use for all animations
  37954. */
  37955. set speedRatio(value: number);
  37956. /**
  37957. * Gets or sets if all animations should loop or not
  37958. */
  37959. get loopAnimation(): boolean;
  37960. set loopAnimation(value: boolean);
  37961. /**
  37962. * Gets or sets if all animations should be evaluated additively
  37963. */
  37964. get isAdditive(): boolean;
  37965. set isAdditive(value: boolean);
  37966. /**
  37967. * Gets the targeted animations for this animation group
  37968. */
  37969. get targetedAnimations(): Array<TargetedAnimation>;
  37970. /**
  37971. * returning the list of animatables controlled by this animation group.
  37972. */
  37973. get animatables(): Array<Animatable>;
  37974. /**
  37975. * Instantiates a new Animation Group.
  37976. * This helps managing several animations at once.
  37977. * @see http://doc.babylonjs.com/how_to/group
  37978. * @param name Defines the name of the group
  37979. * @param scene Defines the scene the group belongs to
  37980. */
  37981. constructor(
  37982. /** The name of the animation group */
  37983. name: string, scene?: Nullable<Scene>);
  37984. /**
  37985. * Add an animation (with its target) in the group
  37986. * @param animation defines the animation we want to add
  37987. * @param target defines the target of the animation
  37988. * @returns the TargetedAnimation object
  37989. */
  37990. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  37991. /**
  37992. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  37993. * It can add constant keys at begin or end
  37994. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  37995. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  37996. * @returns the animation group
  37997. */
  37998. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  37999. private _animationLoopCount;
  38000. private _animationLoopFlags;
  38001. private _processLoop;
  38002. /**
  38003. * Start all animations on given targets
  38004. * @param loop defines if animations must loop
  38005. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38006. * @param from defines the from key (optional)
  38007. * @param to defines the to key (optional)
  38008. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38009. * @returns the current animation group
  38010. */
  38011. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38012. /**
  38013. * Pause all animations
  38014. * @returns the animation group
  38015. */
  38016. pause(): AnimationGroup;
  38017. /**
  38018. * Play all animations to initial state
  38019. * This function will start() the animations if they were not started or will restart() them if they were paused
  38020. * @param loop defines if animations must loop
  38021. * @returns the animation group
  38022. */
  38023. play(loop?: boolean): AnimationGroup;
  38024. /**
  38025. * Reset all animations to initial state
  38026. * @returns the animation group
  38027. */
  38028. reset(): AnimationGroup;
  38029. /**
  38030. * Restart animations from key 0
  38031. * @returns the animation group
  38032. */
  38033. restart(): AnimationGroup;
  38034. /**
  38035. * Stop all animations
  38036. * @returns the animation group
  38037. */
  38038. stop(): AnimationGroup;
  38039. /**
  38040. * Set animation weight for all animatables
  38041. * @param weight defines the weight to use
  38042. * @return the animationGroup
  38043. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38044. */
  38045. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38046. /**
  38047. * Synchronize and normalize all animatables with a source animatable
  38048. * @param root defines the root animatable to synchronize with
  38049. * @return the animationGroup
  38050. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38051. */
  38052. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38053. /**
  38054. * Goes to a specific frame in this animation group
  38055. * @param frame the frame number to go to
  38056. * @return the animationGroup
  38057. */
  38058. goToFrame(frame: number): AnimationGroup;
  38059. /**
  38060. * Dispose all associated resources
  38061. */
  38062. dispose(): void;
  38063. private _checkAnimationGroupEnded;
  38064. /**
  38065. * Clone the current animation group and returns a copy
  38066. * @param newName defines the name of the new group
  38067. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38068. * @returns the new aniamtion group
  38069. */
  38070. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38071. /**
  38072. * Serializes the animationGroup to an object
  38073. * @returns Serialized object
  38074. */
  38075. serialize(): any;
  38076. /**
  38077. * Returns a new AnimationGroup object parsed from the source provided.
  38078. * @param parsedAnimationGroup defines the source
  38079. * @param scene defines the scene that will receive the animationGroup
  38080. * @returns a new AnimationGroup
  38081. */
  38082. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38083. /**
  38084. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38085. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38086. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38087. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38088. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38089. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38090. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38091. */
  38092. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38093. /**
  38094. * Returns the string "AnimationGroup"
  38095. * @returns "AnimationGroup"
  38096. */
  38097. getClassName(): string;
  38098. /**
  38099. * Creates a detailled string about the object
  38100. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38101. * @returns a string representing the object
  38102. */
  38103. toString(fullDetails?: boolean): string;
  38104. }
  38105. }
  38106. declare module BABYLON {
  38107. /**
  38108. * Define an interface for all classes that will hold resources
  38109. */
  38110. export interface IDisposable {
  38111. /**
  38112. * Releases all held resources
  38113. */
  38114. dispose(): void;
  38115. }
  38116. /** Interface defining initialization parameters for Scene class */
  38117. export interface SceneOptions {
  38118. /**
  38119. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38120. * It will improve performance when the number of geometries becomes important.
  38121. */
  38122. useGeometryUniqueIdsMap?: boolean;
  38123. /**
  38124. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38125. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38126. */
  38127. useMaterialMeshMap?: boolean;
  38128. /**
  38129. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38130. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38131. */
  38132. useClonedMeshMap?: boolean;
  38133. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38134. virtual?: boolean;
  38135. }
  38136. /**
  38137. * Represents a scene to be rendered by the engine.
  38138. * @see http://doc.babylonjs.com/features/scene
  38139. */
  38140. export class Scene extends AbstractScene implements IAnimatable {
  38141. /** The fog is deactivated */
  38142. static readonly FOGMODE_NONE: number;
  38143. /** The fog density is following an exponential function */
  38144. static readonly FOGMODE_EXP: number;
  38145. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38146. static readonly FOGMODE_EXP2: number;
  38147. /** The fog density is following a linear function. */
  38148. static readonly FOGMODE_LINEAR: number;
  38149. /**
  38150. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38151. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38152. */
  38153. static MinDeltaTime: number;
  38154. /**
  38155. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38156. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38157. */
  38158. static MaxDeltaTime: number;
  38159. /**
  38160. * Factory used to create the default material.
  38161. * @param name The name of the material to create
  38162. * @param scene The scene to create the material for
  38163. * @returns The default material
  38164. */
  38165. static DefaultMaterialFactory(scene: Scene): Material;
  38166. /**
  38167. * Factory used to create the a collision coordinator.
  38168. * @returns The collision coordinator
  38169. */
  38170. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38171. /** @hidden */
  38172. _inputManager: InputManager;
  38173. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38174. cameraToUseForPointers: Nullable<Camera>;
  38175. /** @hidden */
  38176. readonly _isScene: boolean;
  38177. /** @hidden */
  38178. _blockEntityCollection: boolean;
  38179. /**
  38180. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38181. */
  38182. autoClear: boolean;
  38183. /**
  38184. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38185. */
  38186. autoClearDepthAndStencil: boolean;
  38187. /**
  38188. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38189. */
  38190. clearColor: Color4;
  38191. /**
  38192. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38193. */
  38194. ambientColor: Color3;
  38195. /**
  38196. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38197. * It should only be one of the following (if not the default embedded one):
  38198. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38199. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38200. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38201. * The material properties need to be setup according to the type of texture in use.
  38202. */
  38203. environmentBRDFTexture: BaseTexture;
  38204. /** @hidden */
  38205. protected _environmentTexture: Nullable<BaseTexture>;
  38206. /**
  38207. * Texture used in all pbr material as the reflection texture.
  38208. * As in the majority of the scene they are the same (exception for multi room and so on),
  38209. * this is easier to reference from here than from all the materials.
  38210. */
  38211. get environmentTexture(): Nullable<BaseTexture>;
  38212. /**
  38213. * Texture used in all pbr material as the reflection texture.
  38214. * As in the majority of the scene they are the same (exception for multi room and so on),
  38215. * this is easier to set here than in all the materials.
  38216. */
  38217. set environmentTexture(value: Nullable<BaseTexture>);
  38218. /** @hidden */
  38219. protected _environmentIntensity: number;
  38220. /**
  38221. * Intensity of the environment in all pbr material.
  38222. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38223. * As in the majority of the scene they are the same (exception for multi room and so on),
  38224. * this is easier to reference from here than from all the materials.
  38225. */
  38226. get environmentIntensity(): number;
  38227. /**
  38228. * Intensity of the environment in all pbr material.
  38229. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38230. * As in the majority of the scene they are the same (exception for multi room and so on),
  38231. * this is easier to set here than in all the materials.
  38232. */
  38233. set environmentIntensity(value: number);
  38234. /** @hidden */
  38235. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38236. /**
  38237. * Default image processing configuration used either in the rendering
  38238. * Forward main pass or through the imageProcessingPostProcess if present.
  38239. * As in the majority of the scene they are the same (exception for multi camera),
  38240. * this is easier to reference from here than from all the materials and post process.
  38241. *
  38242. * No setter as we it is a shared configuration, you can set the values instead.
  38243. */
  38244. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38245. private _forceWireframe;
  38246. /**
  38247. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38248. */
  38249. set forceWireframe(value: boolean);
  38250. get forceWireframe(): boolean;
  38251. private _skipFrustumClipping;
  38252. /**
  38253. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38254. */
  38255. set skipFrustumClipping(value: boolean);
  38256. get skipFrustumClipping(): boolean;
  38257. private _forcePointsCloud;
  38258. /**
  38259. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38260. */
  38261. set forcePointsCloud(value: boolean);
  38262. get forcePointsCloud(): boolean;
  38263. /**
  38264. * Gets or sets the active clipplane 1
  38265. */
  38266. clipPlane: Nullable<Plane>;
  38267. /**
  38268. * Gets or sets the active clipplane 2
  38269. */
  38270. clipPlane2: Nullable<Plane>;
  38271. /**
  38272. * Gets or sets the active clipplane 3
  38273. */
  38274. clipPlane3: Nullable<Plane>;
  38275. /**
  38276. * Gets or sets the active clipplane 4
  38277. */
  38278. clipPlane4: Nullable<Plane>;
  38279. /**
  38280. * Gets or sets the active clipplane 5
  38281. */
  38282. clipPlane5: Nullable<Plane>;
  38283. /**
  38284. * Gets or sets the active clipplane 6
  38285. */
  38286. clipPlane6: Nullable<Plane>;
  38287. /**
  38288. * Gets or sets a boolean indicating if animations are enabled
  38289. */
  38290. animationsEnabled: boolean;
  38291. private _animationPropertiesOverride;
  38292. /**
  38293. * Gets or sets the animation properties override
  38294. */
  38295. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38296. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38297. /**
  38298. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38299. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38300. */
  38301. useConstantAnimationDeltaTime: boolean;
  38302. /**
  38303. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38304. * Please note that it requires to run a ray cast through the scene on every frame
  38305. */
  38306. constantlyUpdateMeshUnderPointer: boolean;
  38307. /**
  38308. * Defines the HTML cursor to use when hovering over interactive elements
  38309. */
  38310. hoverCursor: string;
  38311. /**
  38312. * Defines the HTML default cursor to use (empty by default)
  38313. */
  38314. defaultCursor: string;
  38315. /**
  38316. * Defines whether cursors are handled by the scene.
  38317. */
  38318. doNotHandleCursors: boolean;
  38319. /**
  38320. * This is used to call preventDefault() on pointer down
  38321. * in order to block unwanted artifacts like system double clicks
  38322. */
  38323. preventDefaultOnPointerDown: boolean;
  38324. /**
  38325. * This is used to call preventDefault() on pointer up
  38326. * in order to block unwanted artifacts like system double clicks
  38327. */
  38328. preventDefaultOnPointerUp: boolean;
  38329. /**
  38330. * Gets or sets user defined metadata
  38331. */
  38332. metadata: any;
  38333. /**
  38334. * For internal use only. Please do not use.
  38335. */
  38336. reservedDataStore: any;
  38337. /**
  38338. * Gets the name of the plugin used to load this scene (null by default)
  38339. */
  38340. loadingPluginName: string;
  38341. /**
  38342. * Use this array to add regular expressions used to disable offline support for specific urls
  38343. */
  38344. disableOfflineSupportExceptionRules: RegExp[];
  38345. /**
  38346. * An event triggered when the scene is disposed.
  38347. */
  38348. onDisposeObservable: Observable<Scene>;
  38349. private _onDisposeObserver;
  38350. /** Sets a function to be executed when this scene is disposed. */
  38351. set onDispose(callback: () => void);
  38352. /**
  38353. * An event triggered before rendering the scene (right after animations and physics)
  38354. */
  38355. onBeforeRenderObservable: Observable<Scene>;
  38356. private _onBeforeRenderObserver;
  38357. /** Sets a function to be executed before rendering this scene */
  38358. set beforeRender(callback: Nullable<() => void>);
  38359. /**
  38360. * An event triggered after rendering the scene
  38361. */
  38362. onAfterRenderObservable: Observable<Scene>;
  38363. /**
  38364. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38365. */
  38366. onAfterRenderCameraObservable: Observable<Camera>;
  38367. private _onAfterRenderObserver;
  38368. /** Sets a function to be executed after rendering this scene */
  38369. set afterRender(callback: Nullable<() => void>);
  38370. /**
  38371. * An event triggered before animating the scene
  38372. */
  38373. onBeforeAnimationsObservable: Observable<Scene>;
  38374. /**
  38375. * An event triggered after animations processing
  38376. */
  38377. onAfterAnimationsObservable: Observable<Scene>;
  38378. /**
  38379. * An event triggered before draw calls are ready to be sent
  38380. */
  38381. onBeforeDrawPhaseObservable: Observable<Scene>;
  38382. /**
  38383. * An event triggered after draw calls have been sent
  38384. */
  38385. onAfterDrawPhaseObservable: Observable<Scene>;
  38386. /**
  38387. * An event triggered when the scene is ready
  38388. */
  38389. onReadyObservable: Observable<Scene>;
  38390. /**
  38391. * An event triggered before rendering a camera
  38392. */
  38393. onBeforeCameraRenderObservable: Observable<Camera>;
  38394. private _onBeforeCameraRenderObserver;
  38395. /** Sets a function to be executed before rendering a camera*/
  38396. set beforeCameraRender(callback: () => void);
  38397. /**
  38398. * An event triggered after rendering a camera
  38399. */
  38400. onAfterCameraRenderObservable: Observable<Camera>;
  38401. private _onAfterCameraRenderObserver;
  38402. /** Sets a function to be executed after rendering a camera*/
  38403. set afterCameraRender(callback: () => void);
  38404. /**
  38405. * An event triggered when active meshes evaluation is about to start
  38406. */
  38407. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38408. /**
  38409. * An event triggered when active meshes evaluation is done
  38410. */
  38411. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38412. /**
  38413. * An event triggered when particles rendering is about to start
  38414. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38415. */
  38416. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38417. /**
  38418. * An event triggered when particles rendering is done
  38419. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38420. */
  38421. onAfterParticlesRenderingObservable: Observable<Scene>;
  38422. /**
  38423. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38424. */
  38425. onDataLoadedObservable: Observable<Scene>;
  38426. /**
  38427. * An event triggered when a camera is created
  38428. */
  38429. onNewCameraAddedObservable: Observable<Camera>;
  38430. /**
  38431. * An event triggered when a camera is removed
  38432. */
  38433. onCameraRemovedObservable: Observable<Camera>;
  38434. /**
  38435. * An event triggered when a light is created
  38436. */
  38437. onNewLightAddedObservable: Observable<Light>;
  38438. /**
  38439. * An event triggered when a light is removed
  38440. */
  38441. onLightRemovedObservable: Observable<Light>;
  38442. /**
  38443. * An event triggered when a geometry is created
  38444. */
  38445. onNewGeometryAddedObservable: Observable<Geometry>;
  38446. /**
  38447. * An event triggered when a geometry is removed
  38448. */
  38449. onGeometryRemovedObservable: Observable<Geometry>;
  38450. /**
  38451. * An event triggered when a transform node is created
  38452. */
  38453. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38454. /**
  38455. * An event triggered when a transform node is removed
  38456. */
  38457. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38458. /**
  38459. * An event triggered when a mesh is created
  38460. */
  38461. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38462. /**
  38463. * An event triggered when a mesh is removed
  38464. */
  38465. onMeshRemovedObservable: Observable<AbstractMesh>;
  38466. /**
  38467. * An event triggered when a skeleton is created
  38468. */
  38469. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38470. /**
  38471. * An event triggered when a skeleton is removed
  38472. */
  38473. onSkeletonRemovedObservable: Observable<Skeleton>;
  38474. /**
  38475. * An event triggered when a material is created
  38476. */
  38477. onNewMaterialAddedObservable: Observable<Material>;
  38478. /**
  38479. * An event triggered when a material is removed
  38480. */
  38481. onMaterialRemovedObservable: Observable<Material>;
  38482. /**
  38483. * An event triggered when a texture is created
  38484. */
  38485. onNewTextureAddedObservable: Observable<BaseTexture>;
  38486. /**
  38487. * An event triggered when a texture is removed
  38488. */
  38489. onTextureRemovedObservable: Observable<BaseTexture>;
  38490. /**
  38491. * An event triggered when render targets are about to be rendered
  38492. * Can happen multiple times per frame.
  38493. */
  38494. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38495. /**
  38496. * An event triggered when render targets were rendered.
  38497. * Can happen multiple times per frame.
  38498. */
  38499. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38500. /**
  38501. * An event triggered before calculating deterministic simulation step
  38502. */
  38503. onBeforeStepObservable: Observable<Scene>;
  38504. /**
  38505. * An event triggered after calculating deterministic simulation step
  38506. */
  38507. onAfterStepObservable: Observable<Scene>;
  38508. /**
  38509. * An event triggered when the activeCamera property is updated
  38510. */
  38511. onActiveCameraChanged: Observable<Scene>;
  38512. /**
  38513. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38514. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38515. * 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)
  38516. */
  38517. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38518. /**
  38519. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38520. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38521. * 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)
  38522. */
  38523. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38524. /**
  38525. * This Observable will when a mesh has been imported into the scene.
  38526. */
  38527. onMeshImportedObservable: Observable<AbstractMesh>;
  38528. /**
  38529. * This Observable will when an animation file has been imported into the scene.
  38530. */
  38531. onAnimationFileImportedObservable: Observable<Scene>;
  38532. /**
  38533. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38534. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38535. */
  38536. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38537. /** @hidden */
  38538. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38539. /**
  38540. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38541. */
  38542. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38543. /**
  38544. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38545. */
  38546. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38547. /**
  38548. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38549. */
  38550. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38551. /** Callback called when a pointer move is detected */
  38552. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38553. /** Callback called when a pointer down is detected */
  38554. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38555. /** Callback called when a pointer up is detected */
  38556. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38557. /** Callback called when a pointer pick is detected */
  38558. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38559. /**
  38560. * 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).
  38561. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38562. */
  38563. onPrePointerObservable: Observable<PointerInfoPre>;
  38564. /**
  38565. * Observable event triggered each time an input event is received from the rendering canvas
  38566. */
  38567. onPointerObservable: Observable<PointerInfo>;
  38568. /**
  38569. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38570. */
  38571. get unTranslatedPointer(): Vector2;
  38572. /**
  38573. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38574. */
  38575. static get DragMovementThreshold(): number;
  38576. static set DragMovementThreshold(value: number);
  38577. /**
  38578. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38579. */
  38580. static get LongPressDelay(): number;
  38581. static set LongPressDelay(value: number);
  38582. /**
  38583. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38584. */
  38585. static get DoubleClickDelay(): number;
  38586. static set DoubleClickDelay(value: number);
  38587. /** If you need to check double click without raising a single click at first click, enable this flag */
  38588. static get ExclusiveDoubleClickMode(): boolean;
  38589. static set ExclusiveDoubleClickMode(value: boolean);
  38590. /** @hidden */
  38591. _mirroredCameraPosition: Nullable<Vector3>;
  38592. /**
  38593. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38594. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38595. */
  38596. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38597. /**
  38598. * Observable event triggered each time an keyboard event is received from the hosting window
  38599. */
  38600. onKeyboardObservable: Observable<KeyboardInfo>;
  38601. private _useRightHandedSystem;
  38602. /**
  38603. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38604. */
  38605. set useRightHandedSystem(value: boolean);
  38606. get useRightHandedSystem(): boolean;
  38607. private _timeAccumulator;
  38608. private _currentStepId;
  38609. private _currentInternalStep;
  38610. /**
  38611. * Sets the step Id used by deterministic lock step
  38612. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38613. * @param newStepId defines the step Id
  38614. */
  38615. setStepId(newStepId: number): void;
  38616. /**
  38617. * Gets the step Id used by deterministic lock step
  38618. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38619. * @returns the step Id
  38620. */
  38621. getStepId(): number;
  38622. /**
  38623. * Gets the internal step used by deterministic lock step
  38624. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38625. * @returns the internal step
  38626. */
  38627. getInternalStep(): number;
  38628. private _fogEnabled;
  38629. /**
  38630. * Gets or sets a boolean indicating if fog is enabled on this scene
  38631. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38632. * (Default is true)
  38633. */
  38634. set fogEnabled(value: boolean);
  38635. get fogEnabled(): boolean;
  38636. private _fogMode;
  38637. /**
  38638. * Gets or sets the fog mode to use
  38639. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38640. * | mode | value |
  38641. * | --- | --- |
  38642. * | FOGMODE_NONE | 0 |
  38643. * | FOGMODE_EXP | 1 |
  38644. * | FOGMODE_EXP2 | 2 |
  38645. * | FOGMODE_LINEAR | 3 |
  38646. */
  38647. set fogMode(value: number);
  38648. get fogMode(): number;
  38649. /**
  38650. * Gets or sets the fog color to use
  38651. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38652. * (Default is Color3(0.2, 0.2, 0.3))
  38653. */
  38654. fogColor: Color3;
  38655. /**
  38656. * Gets or sets the fog density to use
  38657. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38658. * (Default is 0.1)
  38659. */
  38660. fogDensity: number;
  38661. /**
  38662. * Gets or sets the fog start distance to use
  38663. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38664. * (Default is 0)
  38665. */
  38666. fogStart: number;
  38667. /**
  38668. * Gets or sets the fog end distance to use
  38669. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38670. * (Default is 1000)
  38671. */
  38672. fogEnd: number;
  38673. private _shadowsEnabled;
  38674. /**
  38675. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38676. */
  38677. set shadowsEnabled(value: boolean);
  38678. get shadowsEnabled(): boolean;
  38679. private _lightsEnabled;
  38680. /**
  38681. * Gets or sets a boolean indicating if lights are enabled on this scene
  38682. */
  38683. set lightsEnabled(value: boolean);
  38684. get lightsEnabled(): boolean;
  38685. /** All of the active cameras added to this scene. */
  38686. activeCameras: Camera[];
  38687. /** @hidden */
  38688. _activeCamera: Nullable<Camera>;
  38689. /** Gets or sets the current active camera */
  38690. get activeCamera(): Nullable<Camera>;
  38691. set activeCamera(value: Nullable<Camera>);
  38692. private _defaultMaterial;
  38693. /** The default material used on meshes when no material is affected */
  38694. get defaultMaterial(): Material;
  38695. /** The default material used on meshes when no material is affected */
  38696. set defaultMaterial(value: Material);
  38697. private _texturesEnabled;
  38698. /**
  38699. * Gets or sets a boolean indicating if textures are enabled on this scene
  38700. */
  38701. set texturesEnabled(value: boolean);
  38702. get texturesEnabled(): boolean;
  38703. /**
  38704. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38705. */
  38706. physicsEnabled: boolean;
  38707. /**
  38708. * Gets or sets a boolean indicating if particles are enabled on this scene
  38709. */
  38710. particlesEnabled: boolean;
  38711. /**
  38712. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38713. */
  38714. spritesEnabled: boolean;
  38715. private _skeletonsEnabled;
  38716. /**
  38717. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38718. */
  38719. set skeletonsEnabled(value: boolean);
  38720. get skeletonsEnabled(): boolean;
  38721. /**
  38722. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38723. */
  38724. lensFlaresEnabled: boolean;
  38725. /**
  38726. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38727. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38728. */
  38729. collisionsEnabled: boolean;
  38730. private _collisionCoordinator;
  38731. /** @hidden */
  38732. get collisionCoordinator(): ICollisionCoordinator;
  38733. /**
  38734. * Defines the gravity applied to this scene (used only for collisions)
  38735. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38736. */
  38737. gravity: Vector3;
  38738. /**
  38739. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38740. */
  38741. postProcessesEnabled: boolean;
  38742. /**
  38743. * The list of postprocesses added to the scene
  38744. */
  38745. postProcesses: PostProcess[];
  38746. /**
  38747. * Gets the current postprocess manager
  38748. */
  38749. postProcessManager: PostProcessManager;
  38750. /**
  38751. * Gets or sets a boolean indicating if render targets are enabled on this scene
  38752. */
  38753. renderTargetsEnabled: boolean;
  38754. /**
  38755. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  38756. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  38757. */
  38758. dumpNextRenderTargets: boolean;
  38759. /**
  38760. * The list of user defined render targets added to the scene
  38761. */
  38762. customRenderTargets: RenderTargetTexture[];
  38763. /**
  38764. * Defines if texture loading must be delayed
  38765. * If true, textures will only be loaded when they need to be rendered
  38766. */
  38767. useDelayedTextureLoading: boolean;
  38768. /**
  38769. * Gets the list of meshes imported to the scene through SceneLoader
  38770. */
  38771. importedMeshesFiles: String[];
  38772. /**
  38773. * Gets or sets a boolean indicating if probes are enabled on this scene
  38774. */
  38775. probesEnabled: boolean;
  38776. /**
  38777. * Gets or sets the current offline provider to use to store scene data
  38778. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  38779. */
  38780. offlineProvider: IOfflineProvider;
  38781. /**
  38782. * Gets or sets the action manager associated with the scene
  38783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38784. */
  38785. actionManager: AbstractActionManager;
  38786. private _meshesForIntersections;
  38787. /**
  38788. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  38789. */
  38790. proceduralTexturesEnabled: boolean;
  38791. private _engine;
  38792. private _totalVertices;
  38793. /** @hidden */
  38794. _activeIndices: PerfCounter;
  38795. /** @hidden */
  38796. _activeParticles: PerfCounter;
  38797. /** @hidden */
  38798. _activeBones: PerfCounter;
  38799. private _animationRatio;
  38800. /** @hidden */
  38801. _animationTimeLast: number;
  38802. /** @hidden */
  38803. _animationTime: number;
  38804. /**
  38805. * Gets or sets a general scale for animation speed
  38806. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  38807. */
  38808. animationTimeScale: number;
  38809. /** @hidden */
  38810. _cachedMaterial: Nullable<Material>;
  38811. /** @hidden */
  38812. _cachedEffect: Nullable<Effect>;
  38813. /** @hidden */
  38814. _cachedVisibility: Nullable<number>;
  38815. private _renderId;
  38816. private _frameId;
  38817. private _executeWhenReadyTimeoutId;
  38818. private _intermediateRendering;
  38819. private _viewUpdateFlag;
  38820. private _projectionUpdateFlag;
  38821. /** @hidden */
  38822. _toBeDisposed: Nullable<IDisposable>[];
  38823. private _activeRequests;
  38824. /** @hidden */
  38825. _pendingData: any[];
  38826. private _isDisposed;
  38827. /**
  38828. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  38829. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  38830. */
  38831. dispatchAllSubMeshesOfActiveMeshes: boolean;
  38832. private _activeMeshes;
  38833. private _processedMaterials;
  38834. private _renderTargets;
  38835. /** @hidden */
  38836. _activeParticleSystems: SmartArray<IParticleSystem>;
  38837. private _activeSkeletons;
  38838. private _softwareSkinnedMeshes;
  38839. private _renderingManager;
  38840. /** @hidden */
  38841. _activeAnimatables: Animatable[];
  38842. private _transformMatrix;
  38843. private _sceneUbo;
  38844. /** @hidden */
  38845. _viewMatrix: Matrix;
  38846. private _projectionMatrix;
  38847. /** @hidden */
  38848. _forcedViewPosition: Nullable<Vector3>;
  38849. /** @hidden */
  38850. _frustumPlanes: Plane[];
  38851. /**
  38852. * Gets the list of frustum planes (built from the active camera)
  38853. */
  38854. get frustumPlanes(): Plane[];
  38855. /**
  38856. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  38857. * This is useful if there are more lights that the maximum simulteanous authorized
  38858. */
  38859. requireLightSorting: boolean;
  38860. /** @hidden */
  38861. readonly useMaterialMeshMap: boolean;
  38862. /** @hidden */
  38863. readonly useClonedMeshMap: boolean;
  38864. private _externalData;
  38865. private _uid;
  38866. /**
  38867. * @hidden
  38868. * Backing store of defined scene components.
  38869. */
  38870. _components: ISceneComponent[];
  38871. /**
  38872. * @hidden
  38873. * Backing store of defined scene components.
  38874. */
  38875. _serializableComponents: ISceneSerializableComponent[];
  38876. /**
  38877. * List of components to register on the next registration step.
  38878. */
  38879. private _transientComponents;
  38880. /**
  38881. * Registers the transient components if needed.
  38882. */
  38883. private _registerTransientComponents;
  38884. /**
  38885. * @hidden
  38886. * Add a component to the scene.
  38887. * Note that the ccomponent could be registered on th next frame if this is called after
  38888. * the register component stage.
  38889. * @param component Defines the component to add to the scene
  38890. */
  38891. _addComponent(component: ISceneComponent): void;
  38892. /**
  38893. * @hidden
  38894. * Gets a component from the scene.
  38895. * @param name defines the name of the component to retrieve
  38896. * @returns the component or null if not present
  38897. */
  38898. _getComponent(name: string): Nullable<ISceneComponent>;
  38899. /**
  38900. * @hidden
  38901. * Defines the actions happening before camera updates.
  38902. */
  38903. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  38904. /**
  38905. * @hidden
  38906. * Defines the actions happening before clear the canvas.
  38907. */
  38908. _beforeClearStage: Stage<SimpleStageAction>;
  38909. /**
  38910. * @hidden
  38911. * Defines the actions when collecting render targets for the frame.
  38912. */
  38913. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38914. /**
  38915. * @hidden
  38916. * Defines the actions happening for one camera in the frame.
  38917. */
  38918. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  38919. /**
  38920. * @hidden
  38921. * Defines the actions happening during the per mesh ready checks.
  38922. */
  38923. _isReadyForMeshStage: Stage<MeshStageAction>;
  38924. /**
  38925. * @hidden
  38926. * Defines the actions happening before evaluate active mesh checks.
  38927. */
  38928. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  38929. /**
  38930. * @hidden
  38931. * Defines the actions happening during the evaluate sub mesh checks.
  38932. */
  38933. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  38934. /**
  38935. * @hidden
  38936. * Defines the actions happening during the active mesh stage.
  38937. */
  38938. _activeMeshStage: Stage<ActiveMeshStageAction>;
  38939. /**
  38940. * @hidden
  38941. * Defines the actions happening during the per camera render target step.
  38942. */
  38943. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  38944. /**
  38945. * @hidden
  38946. * Defines the actions happening just before the active camera is drawing.
  38947. */
  38948. _beforeCameraDrawStage: Stage<CameraStageAction>;
  38949. /**
  38950. * @hidden
  38951. * Defines the actions happening just before a render target is drawing.
  38952. */
  38953. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38954. /**
  38955. * @hidden
  38956. * Defines the actions happening just before a rendering group is drawing.
  38957. */
  38958. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38959. /**
  38960. * @hidden
  38961. * Defines the actions happening just before a mesh is drawing.
  38962. */
  38963. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38964. /**
  38965. * @hidden
  38966. * Defines the actions happening just after a mesh has been drawn.
  38967. */
  38968. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  38969. /**
  38970. * @hidden
  38971. * Defines the actions happening just after a rendering group has been drawn.
  38972. */
  38973. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  38974. /**
  38975. * @hidden
  38976. * Defines the actions happening just after the active camera has been drawn.
  38977. */
  38978. _afterCameraDrawStage: Stage<CameraStageAction>;
  38979. /**
  38980. * @hidden
  38981. * Defines the actions happening just after a render target has been drawn.
  38982. */
  38983. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  38984. /**
  38985. * @hidden
  38986. * Defines the actions happening just after rendering all cameras and computing intersections.
  38987. */
  38988. _afterRenderStage: Stage<SimpleStageAction>;
  38989. /**
  38990. * @hidden
  38991. * Defines the actions happening when a pointer move event happens.
  38992. */
  38993. _pointerMoveStage: Stage<PointerMoveStageAction>;
  38994. /**
  38995. * @hidden
  38996. * Defines the actions happening when a pointer down event happens.
  38997. */
  38998. _pointerDownStage: Stage<PointerUpDownStageAction>;
  38999. /**
  39000. * @hidden
  39001. * Defines the actions happening when a pointer up event happens.
  39002. */
  39003. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39004. /**
  39005. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39006. */
  39007. private geometriesByUniqueId;
  39008. /**
  39009. * Creates a new Scene
  39010. * @param engine defines the engine to use to render this scene
  39011. * @param options defines the scene options
  39012. */
  39013. constructor(engine: Engine, options?: SceneOptions);
  39014. /**
  39015. * Gets a string idenfifying the name of the class
  39016. * @returns "Scene" string
  39017. */
  39018. getClassName(): string;
  39019. private _defaultMeshCandidates;
  39020. /**
  39021. * @hidden
  39022. */
  39023. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39024. private _defaultSubMeshCandidates;
  39025. /**
  39026. * @hidden
  39027. */
  39028. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39029. /**
  39030. * Sets the default candidate providers for the scene.
  39031. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39032. * and getCollidingSubMeshCandidates to their default function
  39033. */
  39034. setDefaultCandidateProviders(): void;
  39035. /**
  39036. * Gets the mesh that is currently under the pointer
  39037. */
  39038. get meshUnderPointer(): Nullable<AbstractMesh>;
  39039. /**
  39040. * Gets or sets the current on-screen X position of the pointer
  39041. */
  39042. get pointerX(): number;
  39043. set pointerX(value: number);
  39044. /**
  39045. * Gets or sets the current on-screen Y position of the pointer
  39046. */
  39047. get pointerY(): number;
  39048. set pointerY(value: number);
  39049. /**
  39050. * Gets the cached material (ie. the latest rendered one)
  39051. * @returns the cached material
  39052. */
  39053. getCachedMaterial(): Nullable<Material>;
  39054. /**
  39055. * Gets the cached effect (ie. the latest rendered one)
  39056. * @returns the cached effect
  39057. */
  39058. getCachedEffect(): Nullable<Effect>;
  39059. /**
  39060. * Gets the cached visibility state (ie. the latest rendered one)
  39061. * @returns the cached visibility state
  39062. */
  39063. getCachedVisibility(): Nullable<number>;
  39064. /**
  39065. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39066. * @param material defines the current material
  39067. * @param effect defines the current effect
  39068. * @param visibility defines the current visibility state
  39069. * @returns true if one parameter is not cached
  39070. */
  39071. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39072. /**
  39073. * Gets the engine associated with the scene
  39074. * @returns an Engine
  39075. */
  39076. getEngine(): Engine;
  39077. /**
  39078. * Gets the total number of vertices rendered per frame
  39079. * @returns the total number of vertices rendered per frame
  39080. */
  39081. getTotalVertices(): number;
  39082. /**
  39083. * Gets the performance counter for total vertices
  39084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39085. */
  39086. get totalVerticesPerfCounter(): PerfCounter;
  39087. /**
  39088. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39089. * @returns the total number of active indices rendered per frame
  39090. */
  39091. getActiveIndices(): number;
  39092. /**
  39093. * Gets the performance counter for active indices
  39094. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39095. */
  39096. get totalActiveIndicesPerfCounter(): PerfCounter;
  39097. /**
  39098. * Gets the total number of active particles rendered per frame
  39099. * @returns the total number of active particles rendered per frame
  39100. */
  39101. getActiveParticles(): number;
  39102. /**
  39103. * Gets the performance counter for active particles
  39104. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39105. */
  39106. get activeParticlesPerfCounter(): PerfCounter;
  39107. /**
  39108. * Gets the total number of active bones rendered per frame
  39109. * @returns the total number of active bones rendered per frame
  39110. */
  39111. getActiveBones(): number;
  39112. /**
  39113. * Gets the performance counter for active bones
  39114. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39115. */
  39116. get activeBonesPerfCounter(): PerfCounter;
  39117. /**
  39118. * Gets the array of active meshes
  39119. * @returns an array of AbstractMesh
  39120. */
  39121. getActiveMeshes(): SmartArray<AbstractMesh>;
  39122. /**
  39123. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39124. * @returns a number
  39125. */
  39126. getAnimationRatio(): number;
  39127. /**
  39128. * Gets an unique Id for the current render phase
  39129. * @returns a number
  39130. */
  39131. getRenderId(): number;
  39132. /**
  39133. * Gets an unique Id for the current frame
  39134. * @returns a number
  39135. */
  39136. getFrameId(): number;
  39137. /** Call this function if you want to manually increment the render Id*/
  39138. incrementRenderId(): void;
  39139. private _createUbo;
  39140. /**
  39141. * Use this method to simulate a pointer move on a mesh
  39142. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39143. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39144. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39145. * @returns the current scene
  39146. */
  39147. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39148. /**
  39149. * Use this method to simulate a pointer down on a mesh
  39150. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39151. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39152. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39153. * @returns the current scene
  39154. */
  39155. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39156. /**
  39157. * Use this method to simulate a pointer up on a mesh
  39158. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39159. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39160. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39161. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39162. * @returns the current scene
  39163. */
  39164. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39165. /**
  39166. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39167. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39168. * @returns true if the pointer was captured
  39169. */
  39170. isPointerCaptured(pointerId?: number): boolean;
  39171. /**
  39172. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39173. * @param attachUp defines if you want to attach events to pointerup
  39174. * @param attachDown defines if you want to attach events to pointerdown
  39175. * @param attachMove defines if you want to attach events to pointermove
  39176. */
  39177. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39178. /** Detaches all event handlers*/
  39179. detachControl(): void;
  39180. /**
  39181. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39182. * Delay loaded resources are not taking in account
  39183. * @return true if all required resources are ready
  39184. */
  39185. isReady(): boolean;
  39186. /** Resets all cached information relative to material (including effect and visibility) */
  39187. resetCachedMaterial(): void;
  39188. /**
  39189. * Registers a function to be called before every frame render
  39190. * @param func defines the function to register
  39191. */
  39192. registerBeforeRender(func: () => void): void;
  39193. /**
  39194. * Unregisters a function called before every frame render
  39195. * @param func defines the function to unregister
  39196. */
  39197. unregisterBeforeRender(func: () => void): void;
  39198. /**
  39199. * Registers a function to be called after every frame render
  39200. * @param func defines the function to register
  39201. */
  39202. registerAfterRender(func: () => void): void;
  39203. /**
  39204. * Unregisters a function called after every frame render
  39205. * @param func defines the function to unregister
  39206. */
  39207. unregisterAfterRender(func: () => void): void;
  39208. private _executeOnceBeforeRender;
  39209. /**
  39210. * The provided function will run before render once and will be disposed afterwards.
  39211. * A timeout delay can be provided so that the function will be executed in N ms.
  39212. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39213. * @param func The function to be executed.
  39214. * @param timeout optional delay in ms
  39215. */
  39216. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39217. /** @hidden */
  39218. _addPendingData(data: any): void;
  39219. /** @hidden */
  39220. _removePendingData(data: any): void;
  39221. /**
  39222. * Returns the number of items waiting to be loaded
  39223. * @returns the number of items waiting to be loaded
  39224. */
  39225. getWaitingItemsCount(): number;
  39226. /**
  39227. * Returns a boolean indicating if the scene is still loading data
  39228. */
  39229. get isLoading(): boolean;
  39230. /**
  39231. * Registers a function to be executed when the scene is ready
  39232. * @param {Function} func - the function to be executed
  39233. */
  39234. executeWhenReady(func: () => void): void;
  39235. /**
  39236. * Returns a promise that resolves when the scene is ready
  39237. * @returns A promise that resolves when the scene is ready
  39238. */
  39239. whenReadyAsync(): Promise<void>;
  39240. /** @hidden */
  39241. _checkIsReady(): void;
  39242. /**
  39243. * Gets all animatable attached to the scene
  39244. */
  39245. get animatables(): Animatable[];
  39246. /**
  39247. * Resets the last animation time frame.
  39248. * Useful to override when animations start running when loading a scene for the first time.
  39249. */
  39250. resetLastAnimationTimeFrame(): void;
  39251. /**
  39252. * Gets the current view matrix
  39253. * @returns a Matrix
  39254. */
  39255. getViewMatrix(): Matrix;
  39256. /**
  39257. * Gets the current projection matrix
  39258. * @returns a Matrix
  39259. */
  39260. getProjectionMatrix(): Matrix;
  39261. /**
  39262. * Gets the current transform matrix
  39263. * @returns a Matrix made of View * Projection
  39264. */
  39265. getTransformMatrix(): Matrix;
  39266. /**
  39267. * Sets the current transform matrix
  39268. * @param viewL defines the View matrix to use
  39269. * @param projectionL defines the Projection matrix to use
  39270. * @param viewR defines the right View matrix to use (if provided)
  39271. * @param projectionR defines the right Projection matrix to use (if provided)
  39272. */
  39273. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39274. /**
  39275. * Gets the uniform buffer used to store scene data
  39276. * @returns a UniformBuffer
  39277. */
  39278. getSceneUniformBuffer(): UniformBuffer;
  39279. /**
  39280. * Gets an unique (relatively to the current scene) Id
  39281. * @returns an unique number for the scene
  39282. */
  39283. getUniqueId(): number;
  39284. /**
  39285. * Add a mesh to the list of scene's meshes
  39286. * @param newMesh defines the mesh to add
  39287. * @param recursive if all child meshes should also be added to the scene
  39288. */
  39289. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39290. /**
  39291. * Remove a mesh for the list of scene's meshes
  39292. * @param toRemove defines the mesh to remove
  39293. * @param recursive if all child meshes should also be removed from the scene
  39294. * @returns the index where the mesh was in the mesh list
  39295. */
  39296. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39297. /**
  39298. * Add a transform node to the list of scene's transform nodes
  39299. * @param newTransformNode defines the transform node to add
  39300. */
  39301. addTransformNode(newTransformNode: TransformNode): void;
  39302. /**
  39303. * Remove a transform node for the list of scene's transform nodes
  39304. * @param toRemove defines the transform node to remove
  39305. * @returns the index where the transform node was in the transform node list
  39306. */
  39307. removeTransformNode(toRemove: TransformNode): number;
  39308. /**
  39309. * Remove a skeleton for the list of scene's skeletons
  39310. * @param toRemove defines the skeleton to remove
  39311. * @returns the index where the skeleton was in the skeleton list
  39312. */
  39313. removeSkeleton(toRemove: Skeleton): number;
  39314. /**
  39315. * Remove a morph target for the list of scene's morph targets
  39316. * @param toRemove defines the morph target to remove
  39317. * @returns the index where the morph target was in the morph target list
  39318. */
  39319. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39320. /**
  39321. * Remove a light for the list of scene's lights
  39322. * @param toRemove defines the light to remove
  39323. * @returns the index where the light was in the light list
  39324. */
  39325. removeLight(toRemove: Light): number;
  39326. /**
  39327. * Remove a camera for the list of scene's cameras
  39328. * @param toRemove defines the camera to remove
  39329. * @returns the index where the camera was in the camera list
  39330. */
  39331. removeCamera(toRemove: Camera): number;
  39332. /**
  39333. * Remove a particle system for the list of scene's particle systems
  39334. * @param toRemove defines the particle system to remove
  39335. * @returns the index where the particle system was in the particle system list
  39336. */
  39337. removeParticleSystem(toRemove: IParticleSystem): number;
  39338. /**
  39339. * Remove a animation for the list of scene's animations
  39340. * @param toRemove defines the animation to remove
  39341. * @returns the index where the animation was in the animation list
  39342. */
  39343. removeAnimation(toRemove: Animation): number;
  39344. /**
  39345. * Will stop the animation of the given target
  39346. * @param target - the target
  39347. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39348. * @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)
  39349. */
  39350. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39351. /**
  39352. * Removes the given animation group from this scene.
  39353. * @param toRemove The animation group to remove
  39354. * @returns The index of the removed animation group
  39355. */
  39356. removeAnimationGroup(toRemove: AnimationGroup): number;
  39357. /**
  39358. * Removes the given multi-material from this scene.
  39359. * @param toRemove The multi-material to remove
  39360. * @returns The index of the removed multi-material
  39361. */
  39362. removeMultiMaterial(toRemove: MultiMaterial): number;
  39363. /**
  39364. * Removes the given material from this scene.
  39365. * @param toRemove The material to remove
  39366. * @returns The index of the removed material
  39367. */
  39368. removeMaterial(toRemove: Material): number;
  39369. /**
  39370. * Removes the given action manager from this scene.
  39371. * @param toRemove The action manager to remove
  39372. * @returns The index of the removed action manager
  39373. */
  39374. removeActionManager(toRemove: AbstractActionManager): number;
  39375. /**
  39376. * Removes the given texture from this scene.
  39377. * @param toRemove The texture to remove
  39378. * @returns The index of the removed texture
  39379. */
  39380. removeTexture(toRemove: BaseTexture): number;
  39381. /**
  39382. * Adds the given light to this scene
  39383. * @param newLight The light to add
  39384. */
  39385. addLight(newLight: Light): void;
  39386. /**
  39387. * Sorts the list list based on light priorities
  39388. */
  39389. sortLightsByPriority(): void;
  39390. /**
  39391. * Adds the given camera to this scene
  39392. * @param newCamera The camera to add
  39393. */
  39394. addCamera(newCamera: Camera): void;
  39395. /**
  39396. * Adds the given skeleton to this scene
  39397. * @param newSkeleton The skeleton to add
  39398. */
  39399. addSkeleton(newSkeleton: Skeleton): void;
  39400. /**
  39401. * Adds the given particle system to this scene
  39402. * @param newParticleSystem The particle system to add
  39403. */
  39404. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39405. /**
  39406. * Adds the given animation to this scene
  39407. * @param newAnimation The animation to add
  39408. */
  39409. addAnimation(newAnimation: Animation): void;
  39410. /**
  39411. * Adds the given animation group to this scene.
  39412. * @param newAnimationGroup The animation group to add
  39413. */
  39414. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39415. /**
  39416. * Adds the given multi-material to this scene
  39417. * @param newMultiMaterial The multi-material to add
  39418. */
  39419. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39420. /**
  39421. * Adds the given material to this scene
  39422. * @param newMaterial The material to add
  39423. */
  39424. addMaterial(newMaterial: Material): void;
  39425. /**
  39426. * Adds the given morph target to this scene
  39427. * @param newMorphTargetManager The morph target to add
  39428. */
  39429. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39430. /**
  39431. * Adds the given geometry to this scene
  39432. * @param newGeometry The geometry to add
  39433. */
  39434. addGeometry(newGeometry: Geometry): void;
  39435. /**
  39436. * Adds the given action manager to this scene
  39437. * @param newActionManager The action manager to add
  39438. */
  39439. addActionManager(newActionManager: AbstractActionManager): void;
  39440. /**
  39441. * Adds the given texture to this scene.
  39442. * @param newTexture The texture to add
  39443. */
  39444. addTexture(newTexture: BaseTexture): void;
  39445. /**
  39446. * Switch active camera
  39447. * @param newCamera defines the new active camera
  39448. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39449. */
  39450. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39451. /**
  39452. * sets the active camera of the scene using its ID
  39453. * @param id defines the camera's ID
  39454. * @return the new active camera or null if none found.
  39455. */
  39456. setActiveCameraByID(id: string): Nullable<Camera>;
  39457. /**
  39458. * sets the active camera of the scene using its name
  39459. * @param name defines the camera's name
  39460. * @returns the new active camera or null if none found.
  39461. */
  39462. setActiveCameraByName(name: string): Nullable<Camera>;
  39463. /**
  39464. * get an animation group using its name
  39465. * @param name defines the material's name
  39466. * @return the animation group or null if none found.
  39467. */
  39468. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39469. /**
  39470. * Get a material using its unique id
  39471. * @param uniqueId defines the material's unique id
  39472. * @return the material or null if none found.
  39473. */
  39474. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39475. /**
  39476. * get a material using its id
  39477. * @param id defines the material's ID
  39478. * @return the material or null if none found.
  39479. */
  39480. getMaterialByID(id: string): Nullable<Material>;
  39481. /**
  39482. * Gets a the last added material using a given id
  39483. * @param id defines the material's ID
  39484. * @return the last material with the given id or null if none found.
  39485. */
  39486. getLastMaterialByID(id: string): Nullable<Material>;
  39487. /**
  39488. * Gets a material using its name
  39489. * @param name defines the material's name
  39490. * @return the material or null if none found.
  39491. */
  39492. getMaterialByName(name: string): Nullable<Material>;
  39493. /**
  39494. * Get a texture using its unique id
  39495. * @param uniqueId defines the texture's unique id
  39496. * @return the texture or null if none found.
  39497. */
  39498. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39499. /**
  39500. * Gets a camera using its id
  39501. * @param id defines the id to look for
  39502. * @returns the camera or null if not found
  39503. */
  39504. getCameraByID(id: string): Nullable<Camera>;
  39505. /**
  39506. * Gets a camera using its unique id
  39507. * @param uniqueId defines the unique id to look for
  39508. * @returns the camera or null if not found
  39509. */
  39510. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39511. /**
  39512. * Gets a camera using its name
  39513. * @param name defines the camera's name
  39514. * @return the camera or null if none found.
  39515. */
  39516. getCameraByName(name: string): Nullable<Camera>;
  39517. /**
  39518. * Gets a bone using its id
  39519. * @param id defines the bone's id
  39520. * @return the bone or null if not found
  39521. */
  39522. getBoneByID(id: string): Nullable<Bone>;
  39523. /**
  39524. * Gets a bone using its id
  39525. * @param name defines the bone's name
  39526. * @return the bone or null if not found
  39527. */
  39528. getBoneByName(name: string): Nullable<Bone>;
  39529. /**
  39530. * Gets a light node using its name
  39531. * @param name defines the the light's name
  39532. * @return the light or null if none found.
  39533. */
  39534. getLightByName(name: string): Nullable<Light>;
  39535. /**
  39536. * Gets a light node using its id
  39537. * @param id defines the light's id
  39538. * @return the light or null if none found.
  39539. */
  39540. getLightByID(id: string): Nullable<Light>;
  39541. /**
  39542. * Gets a light node using its scene-generated unique ID
  39543. * @param uniqueId defines the light's unique id
  39544. * @return the light or null if none found.
  39545. */
  39546. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39547. /**
  39548. * Gets a particle system by id
  39549. * @param id defines the particle system id
  39550. * @return the corresponding system or null if none found
  39551. */
  39552. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39553. /**
  39554. * Gets a geometry using its ID
  39555. * @param id defines the geometry's id
  39556. * @return the geometry or null if none found.
  39557. */
  39558. getGeometryByID(id: string): Nullable<Geometry>;
  39559. private _getGeometryByUniqueID;
  39560. /**
  39561. * Add a new geometry to this scene
  39562. * @param geometry defines the geometry to be added to the scene.
  39563. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39564. * @return a boolean defining if the geometry was added or not
  39565. */
  39566. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39567. /**
  39568. * Removes an existing geometry
  39569. * @param geometry defines the geometry to be removed from the scene
  39570. * @return a boolean defining if the geometry was removed or not
  39571. */
  39572. removeGeometry(geometry: Geometry): boolean;
  39573. /**
  39574. * Gets the list of geometries attached to the scene
  39575. * @returns an array of Geometry
  39576. */
  39577. getGeometries(): Geometry[];
  39578. /**
  39579. * Gets the first added mesh found of a given ID
  39580. * @param id defines the id to search for
  39581. * @return the mesh found or null if not found at all
  39582. */
  39583. getMeshByID(id: string): Nullable<AbstractMesh>;
  39584. /**
  39585. * Gets a list of meshes using their id
  39586. * @param id defines the id to search for
  39587. * @returns a list of meshes
  39588. */
  39589. getMeshesByID(id: string): Array<AbstractMesh>;
  39590. /**
  39591. * Gets the first added transform node found of a given ID
  39592. * @param id defines the id to search for
  39593. * @return the found transform node or null if not found at all.
  39594. */
  39595. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39596. /**
  39597. * Gets a transform node with its auto-generated unique id
  39598. * @param uniqueId efines the unique id to search for
  39599. * @return the found transform node or null if not found at all.
  39600. */
  39601. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39602. /**
  39603. * Gets a list of transform nodes using their id
  39604. * @param id defines the id to search for
  39605. * @returns a list of transform nodes
  39606. */
  39607. getTransformNodesByID(id: string): Array<TransformNode>;
  39608. /**
  39609. * Gets a mesh with its auto-generated unique id
  39610. * @param uniqueId defines the unique id to search for
  39611. * @return the found mesh or null if not found at all.
  39612. */
  39613. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39614. /**
  39615. * Gets a the last added mesh using a given id
  39616. * @param id defines the id to search for
  39617. * @return the found mesh or null if not found at all.
  39618. */
  39619. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39620. /**
  39621. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39622. * @param id defines the id to search for
  39623. * @return the found node or null if not found at all
  39624. */
  39625. getLastEntryByID(id: string): Nullable<Node>;
  39626. /**
  39627. * Gets a node (Mesh, Camera, Light) using a given id
  39628. * @param id defines the id to search for
  39629. * @return the found node or null if not found at all
  39630. */
  39631. getNodeByID(id: string): Nullable<Node>;
  39632. /**
  39633. * Gets a node (Mesh, Camera, Light) using a given name
  39634. * @param name defines the name to search for
  39635. * @return the found node or null if not found at all.
  39636. */
  39637. getNodeByName(name: string): Nullable<Node>;
  39638. /**
  39639. * Gets a mesh using a given name
  39640. * @param name defines the name to search for
  39641. * @return the found mesh or null if not found at all.
  39642. */
  39643. getMeshByName(name: string): Nullable<AbstractMesh>;
  39644. /**
  39645. * Gets a transform node using a given name
  39646. * @param name defines the name to search for
  39647. * @return the found transform node or null if not found at all.
  39648. */
  39649. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39650. /**
  39651. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39652. * @param id defines the id to search for
  39653. * @return the found skeleton or null if not found at all.
  39654. */
  39655. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39656. /**
  39657. * Gets a skeleton using a given auto generated unique id
  39658. * @param uniqueId defines the unique id to search for
  39659. * @return the found skeleton or null if not found at all.
  39660. */
  39661. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39662. /**
  39663. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39664. * @param id defines the id to search for
  39665. * @return the found skeleton or null if not found at all.
  39666. */
  39667. getSkeletonById(id: string): Nullable<Skeleton>;
  39668. /**
  39669. * Gets a skeleton using a given name
  39670. * @param name defines the name to search for
  39671. * @return the found skeleton or null if not found at all.
  39672. */
  39673. getSkeletonByName(name: string): Nullable<Skeleton>;
  39674. /**
  39675. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39676. * @param id defines the id to search for
  39677. * @return the found morph target manager or null if not found at all.
  39678. */
  39679. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39680. /**
  39681. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39682. * @param id defines the id to search for
  39683. * @return the found morph target or null if not found at all.
  39684. */
  39685. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39686. /**
  39687. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39688. * @param name defines the name to search for
  39689. * @return the found morph target or null if not found at all.
  39690. */
  39691. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39692. /**
  39693. * Gets a boolean indicating if the given mesh is active
  39694. * @param mesh defines the mesh to look for
  39695. * @returns true if the mesh is in the active list
  39696. */
  39697. isActiveMesh(mesh: AbstractMesh): boolean;
  39698. /**
  39699. * Return a unique id as a string which can serve as an identifier for the scene
  39700. */
  39701. get uid(): string;
  39702. /**
  39703. * Add an externaly attached data from its key.
  39704. * This method call will fail and return false, if such key already exists.
  39705. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39706. * @param key the unique key that identifies the data
  39707. * @param data the data object to associate to the key for this Engine instance
  39708. * @return true if no such key were already present and the data was added successfully, false otherwise
  39709. */
  39710. addExternalData<T>(key: string, data: T): boolean;
  39711. /**
  39712. * Get an externaly attached data from its key
  39713. * @param key the unique key that identifies the data
  39714. * @return the associated data, if present (can be null), or undefined if not present
  39715. */
  39716. getExternalData<T>(key: string): Nullable<T>;
  39717. /**
  39718. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39719. * @param key the unique key that identifies the data
  39720. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39721. * @return the associated data, can be null if the factory returned null.
  39722. */
  39723. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39724. /**
  39725. * Remove an externaly attached data from the Engine instance
  39726. * @param key the unique key that identifies the data
  39727. * @return true if the data was successfully removed, false if it doesn't exist
  39728. */
  39729. removeExternalData(key: string): boolean;
  39730. private _evaluateSubMesh;
  39731. /**
  39732. * Clear the processed materials smart array preventing retention point in material dispose.
  39733. */
  39734. freeProcessedMaterials(): void;
  39735. private _preventFreeActiveMeshesAndRenderingGroups;
  39736. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39737. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39738. * when disposing several meshes in a row or a hierarchy of meshes.
  39739. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39740. */
  39741. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39742. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39743. /**
  39744. * Clear the active meshes smart array preventing retention point in mesh dispose.
  39745. */
  39746. freeActiveMeshes(): void;
  39747. /**
  39748. * Clear the info related to rendering groups preventing retention points during dispose.
  39749. */
  39750. freeRenderingGroups(): void;
  39751. /** @hidden */
  39752. _isInIntermediateRendering(): boolean;
  39753. /**
  39754. * Lambda returning the list of potentially active meshes.
  39755. */
  39756. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  39757. /**
  39758. * Lambda returning the list of potentially active sub meshes.
  39759. */
  39760. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  39761. /**
  39762. * Lambda returning the list of potentially intersecting sub meshes.
  39763. */
  39764. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  39765. /**
  39766. * Lambda returning the list of potentially colliding sub meshes.
  39767. */
  39768. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  39769. private _activeMeshesFrozen;
  39770. private _skipEvaluateActiveMeshesCompletely;
  39771. /**
  39772. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  39773. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  39774. * @returns the current scene
  39775. */
  39776. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  39777. /**
  39778. * Use this function to restart evaluating active meshes on every frame
  39779. * @returns the current scene
  39780. */
  39781. unfreezeActiveMeshes(): Scene;
  39782. private _evaluateActiveMeshes;
  39783. private _activeMesh;
  39784. /**
  39785. * Update the transform matrix to update from the current active camera
  39786. * @param force defines a boolean used to force the update even if cache is up to date
  39787. */
  39788. updateTransformMatrix(force?: boolean): void;
  39789. private _bindFrameBuffer;
  39790. /** @hidden */
  39791. _allowPostProcessClearColor: boolean;
  39792. /** @hidden */
  39793. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  39794. private _processSubCameras;
  39795. private _checkIntersections;
  39796. /** @hidden */
  39797. _advancePhysicsEngineStep(step: number): void;
  39798. /**
  39799. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  39800. */
  39801. getDeterministicFrameTime: () => number;
  39802. /** @hidden */
  39803. _animate(): void;
  39804. /** Execute all animations (for a frame) */
  39805. animate(): void;
  39806. /**
  39807. * Render the scene
  39808. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  39809. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  39810. */
  39811. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  39812. /**
  39813. * Freeze all materials
  39814. * A frozen material will not be updatable but should be faster to render
  39815. */
  39816. freezeMaterials(): void;
  39817. /**
  39818. * Unfreeze all materials
  39819. * A frozen material will not be updatable but should be faster to render
  39820. */
  39821. unfreezeMaterials(): void;
  39822. /**
  39823. * Releases all held ressources
  39824. */
  39825. dispose(): void;
  39826. /**
  39827. * Gets if the scene is already disposed
  39828. */
  39829. get isDisposed(): boolean;
  39830. /**
  39831. * Call this function to reduce memory footprint of the scene.
  39832. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  39833. */
  39834. clearCachedVertexData(): void;
  39835. /**
  39836. * This function will remove the local cached buffer data from texture.
  39837. * It will save memory but will prevent the texture from being rebuilt
  39838. */
  39839. cleanCachedTextureBuffer(): void;
  39840. /**
  39841. * Get the world extend vectors with an optional filter
  39842. *
  39843. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  39844. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  39845. */
  39846. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  39847. min: Vector3;
  39848. max: Vector3;
  39849. };
  39850. /**
  39851. * Creates a ray that can be used to pick in the scene
  39852. * @param x defines the x coordinate of the origin (on-screen)
  39853. * @param y defines the y coordinate of the origin (on-screen)
  39854. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39855. * @param camera defines the camera to use for the picking
  39856. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39857. * @returns a Ray
  39858. */
  39859. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  39860. /**
  39861. * Creates a ray that can be used to pick in the scene
  39862. * @param x defines the x coordinate of the origin (on-screen)
  39863. * @param y defines the y coordinate of the origin (on-screen)
  39864. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  39865. * @param result defines the ray where to store the picking ray
  39866. * @param camera defines the camera to use for the picking
  39867. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  39868. * @returns the current scene
  39869. */
  39870. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  39871. /**
  39872. * Creates a ray that can be used to pick in the scene
  39873. * @param x defines the x coordinate of the origin (on-screen)
  39874. * @param y defines the y coordinate of the origin (on-screen)
  39875. * @param camera defines the camera to use for the picking
  39876. * @returns a Ray
  39877. */
  39878. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  39879. /**
  39880. * Creates a ray that can be used to pick in the scene
  39881. * @param x defines the x coordinate of the origin (on-screen)
  39882. * @param y defines the y coordinate of the origin (on-screen)
  39883. * @param result defines the ray where to store the picking ray
  39884. * @param camera defines the camera to use for the picking
  39885. * @returns the current scene
  39886. */
  39887. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  39888. /** Launch a ray to try to pick a mesh in the scene
  39889. * @param x position on screen
  39890. * @param y position on screen
  39891. * @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
  39892. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39893. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39894. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39895. * @returns a PickingInfo
  39896. */
  39897. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39898. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  39899. * @param x position on screen
  39900. * @param y position on screen
  39901. * @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
  39902. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39903. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39904. * @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)
  39905. */
  39906. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  39907. /** Use the given ray to pick a mesh in the scene
  39908. * @param ray The ray to use to pick meshes
  39909. * @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
  39910. * @param fastCheck defines if the first intersection will be used (and not the closest)
  39911. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39912. * @returns a PickingInfo
  39913. */
  39914. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  39915. /**
  39916. * Launch a ray to try to pick a mesh in the scene
  39917. * @param x X position on screen
  39918. * @param y Y position on screen
  39919. * @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
  39920. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  39921. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39922. * @returns an array of PickingInfo
  39923. */
  39924. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39925. /**
  39926. * Launch a ray to try to pick a mesh in the scene
  39927. * @param ray Ray to use
  39928. * @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
  39929. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  39930. * @returns an array of PickingInfo
  39931. */
  39932. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  39933. /**
  39934. * Force the value of meshUnderPointer
  39935. * @param mesh defines the mesh to use
  39936. */
  39937. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39938. /**
  39939. * Gets the mesh under the pointer
  39940. * @returns a Mesh or null if no mesh is under the pointer
  39941. */
  39942. getPointerOverMesh(): Nullable<AbstractMesh>;
  39943. /** @hidden */
  39944. _rebuildGeometries(): void;
  39945. /** @hidden */
  39946. _rebuildTextures(): void;
  39947. private _getByTags;
  39948. /**
  39949. * Get a list of meshes by tags
  39950. * @param tagsQuery defines the tags query to use
  39951. * @param forEach defines a predicate used to filter results
  39952. * @returns an array of Mesh
  39953. */
  39954. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  39955. /**
  39956. * Get a list of cameras by tags
  39957. * @param tagsQuery defines the tags query to use
  39958. * @param forEach defines a predicate used to filter results
  39959. * @returns an array of Camera
  39960. */
  39961. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  39962. /**
  39963. * Get a list of lights by tags
  39964. * @param tagsQuery defines the tags query to use
  39965. * @param forEach defines a predicate used to filter results
  39966. * @returns an array of Light
  39967. */
  39968. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  39969. /**
  39970. * Get a list of materials by tags
  39971. * @param tagsQuery defines the tags query to use
  39972. * @param forEach defines a predicate used to filter results
  39973. * @returns an array of Material
  39974. */
  39975. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  39976. /**
  39977. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39978. * This allowed control for front to back rendering or reversly depending of the special needs.
  39979. *
  39980. * @param renderingGroupId The rendering group id corresponding to its index
  39981. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39982. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39983. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39984. */
  39985. 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;
  39986. /**
  39987. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39988. *
  39989. * @param renderingGroupId The rendering group id corresponding to its index
  39990. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39991. * @param depth Automatically clears depth between groups if true and autoClear is true.
  39992. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  39993. */
  39994. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  39995. /**
  39996. * Gets the current auto clear configuration for one rendering group of the rendering
  39997. * manager.
  39998. * @param index the rendering group index to get the information for
  39999. * @returns The auto clear setup for the requested rendering group
  40000. */
  40001. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40002. private _blockMaterialDirtyMechanism;
  40003. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40004. get blockMaterialDirtyMechanism(): boolean;
  40005. set blockMaterialDirtyMechanism(value: boolean);
  40006. /**
  40007. * Will flag all materials as dirty to trigger new shader compilation
  40008. * @param flag defines the flag used to specify which material part must be marked as dirty
  40009. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40010. */
  40011. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40012. /** @hidden */
  40013. _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;
  40014. /** @hidden */
  40015. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40016. /** @hidden */
  40017. _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;
  40018. /** @hidden */
  40019. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40020. /** @hidden */
  40021. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40022. /** @hidden */
  40023. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40024. }
  40025. }
  40026. declare module BABYLON {
  40027. /**
  40028. * Set of assets to keep when moving a scene into an asset container.
  40029. */
  40030. export class KeepAssets extends AbstractScene {
  40031. }
  40032. /**
  40033. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40034. */
  40035. export class InstantiatedEntries {
  40036. /**
  40037. * List of new root nodes (eg. nodes with no parent)
  40038. */
  40039. rootNodes: TransformNode[];
  40040. /**
  40041. * List of new skeletons
  40042. */
  40043. skeletons: Skeleton[];
  40044. /**
  40045. * List of new animation groups
  40046. */
  40047. animationGroups: AnimationGroup[];
  40048. }
  40049. /**
  40050. * Container with a set of assets that can be added or removed from a scene.
  40051. */
  40052. export class AssetContainer extends AbstractScene {
  40053. private _wasAddedToScene;
  40054. /**
  40055. * The scene the AssetContainer belongs to.
  40056. */
  40057. scene: Scene;
  40058. /**
  40059. * Instantiates an AssetContainer.
  40060. * @param scene The scene the AssetContainer belongs to.
  40061. */
  40062. constructor(scene: Scene);
  40063. /**
  40064. * Instantiate or clone all meshes and add the new ones to the scene.
  40065. * Skeletons and animation groups will all be cloned
  40066. * @param nameFunction defines an optional function used to get new names for clones
  40067. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40068. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40069. */
  40070. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40071. /**
  40072. * Adds all the assets from the container to the scene.
  40073. */
  40074. addAllToScene(): void;
  40075. /**
  40076. * Removes all the assets in the container from the scene
  40077. */
  40078. removeAllFromScene(): void;
  40079. /**
  40080. * Disposes all the assets in the container
  40081. */
  40082. dispose(): void;
  40083. private _moveAssets;
  40084. /**
  40085. * Removes all the assets contained in the scene and adds them to the container.
  40086. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40087. */
  40088. moveAllFromScene(keepAssets?: KeepAssets): void;
  40089. /**
  40090. * 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.
  40091. * @returns the root mesh
  40092. */
  40093. createRootMesh(): Mesh;
  40094. /**
  40095. * Merge animations (direct and animation groups) from this asset container into a scene
  40096. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40097. * @param animatables set of animatables to retarget to a node from the scene
  40098. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40099. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40100. */
  40101. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40102. }
  40103. }
  40104. declare module BABYLON {
  40105. /**
  40106. * Defines how the parser contract is defined.
  40107. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40108. */
  40109. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40110. /**
  40111. * Defines how the individual parser contract is defined.
  40112. * These parser can parse an individual asset
  40113. */
  40114. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40115. /**
  40116. * Base class of the scene acting as a container for the different elements composing a scene.
  40117. * This class is dynamically extended by the different components of the scene increasing
  40118. * flexibility and reducing coupling
  40119. */
  40120. export abstract class AbstractScene {
  40121. /**
  40122. * Stores the list of available parsers in the application.
  40123. */
  40124. private static _BabylonFileParsers;
  40125. /**
  40126. * Stores the list of available individual parsers in the application.
  40127. */
  40128. private static _IndividualBabylonFileParsers;
  40129. /**
  40130. * Adds a parser in the list of available ones
  40131. * @param name Defines the name of the parser
  40132. * @param parser Defines the parser to add
  40133. */
  40134. static AddParser(name: string, parser: BabylonFileParser): void;
  40135. /**
  40136. * Gets a general parser from the list of avaialble ones
  40137. * @param name Defines the name of the parser
  40138. * @returns the requested parser or null
  40139. */
  40140. static GetParser(name: string): Nullable<BabylonFileParser>;
  40141. /**
  40142. * Adds n individual parser in the list of available ones
  40143. * @param name Defines the name of the parser
  40144. * @param parser Defines the parser to add
  40145. */
  40146. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40147. /**
  40148. * Gets an individual parser from the list of avaialble ones
  40149. * @param name Defines the name of the parser
  40150. * @returns the requested parser or null
  40151. */
  40152. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40153. /**
  40154. * Parser json data and populate both a scene and its associated container object
  40155. * @param jsonData Defines the data to parse
  40156. * @param scene Defines the scene to parse the data for
  40157. * @param container Defines the container attached to the parsing sequence
  40158. * @param rootUrl Defines the root url of the data
  40159. */
  40160. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40161. /**
  40162. * Gets the list of root nodes (ie. nodes with no parent)
  40163. */
  40164. rootNodes: Node[];
  40165. /** All of the cameras added to this scene
  40166. * @see http://doc.babylonjs.com/babylon101/cameras
  40167. */
  40168. cameras: Camera[];
  40169. /**
  40170. * All of the lights added to this scene
  40171. * @see http://doc.babylonjs.com/babylon101/lights
  40172. */
  40173. lights: Light[];
  40174. /**
  40175. * All of the (abstract) meshes added to this scene
  40176. */
  40177. meshes: AbstractMesh[];
  40178. /**
  40179. * The list of skeletons added to the scene
  40180. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40181. */
  40182. skeletons: Skeleton[];
  40183. /**
  40184. * All of the particle systems added to this scene
  40185. * @see http://doc.babylonjs.com/babylon101/particles
  40186. */
  40187. particleSystems: IParticleSystem[];
  40188. /**
  40189. * Gets a list of Animations associated with the scene
  40190. */
  40191. animations: Animation[];
  40192. /**
  40193. * All of the animation groups added to this scene
  40194. * @see http://doc.babylonjs.com/how_to/group
  40195. */
  40196. animationGroups: AnimationGroup[];
  40197. /**
  40198. * All of the multi-materials added to this scene
  40199. * @see http://doc.babylonjs.com/how_to/multi_materials
  40200. */
  40201. multiMaterials: MultiMaterial[];
  40202. /**
  40203. * All of the materials added to this scene
  40204. * In the context of a Scene, it is not supposed to be modified manually.
  40205. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40206. * Note also that the order of the Material within the array is not significant and might change.
  40207. * @see http://doc.babylonjs.com/babylon101/materials
  40208. */
  40209. materials: Material[];
  40210. /**
  40211. * The list of morph target managers added to the scene
  40212. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40213. */
  40214. morphTargetManagers: MorphTargetManager[];
  40215. /**
  40216. * The list of geometries used in the scene.
  40217. */
  40218. geometries: Geometry[];
  40219. /**
  40220. * All of the tranform nodes added to this scene
  40221. * In the context of a Scene, it is not supposed to be modified manually.
  40222. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40223. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40224. * @see http://doc.babylonjs.com/how_to/transformnode
  40225. */
  40226. transformNodes: TransformNode[];
  40227. /**
  40228. * ActionManagers available on the scene.
  40229. */
  40230. actionManagers: AbstractActionManager[];
  40231. /**
  40232. * Textures to keep.
  40233. */
  40234. textures: BaseTexture[];
  40235. /**
  40236. * Environment texture for the scene
  40237. */
  40238. environmentTexture: Nullable<BaseTexture>;
  40239. /**
  40240. * @returns all meshes, lights, cameras, transformNodes and bones
  40241. */
  40242. getNodes(): Array<Node>;
  40243. }
  40244. }
  40245. declare module BABYLON {
  40246. /**
  40247. * Interface used to define options for Sound class
  40248. */
  40249. export interface ISoundOptions {
  40250. /**
  40251. * Does the sound autoplay once loaded.
  40252. */
  40253. autoplay?: boolean;
  40254. /**
  40255. * Does the sound loop after it finishes playing once.
  40256. */
  40257. loop?: boolean;
  40258. /**
  40259. * Sound's volume
  40260. */
  40261. volume?: number;
  40262. /**
  40263. * Is it a spatial sound?
  40264. */
  40265. spatialSound?: boolean;
  40266. /**
  40267. * Maximum distance to hear that sound
  40268. */
  40269. maxDistance?: number;
  40270. /**
  40271. * Uses user defined attenuation function
  40272. */
  40273. useCustomAttenuation?: boolean;
  40274. /**
  40275. * Define the roll off factor of spatial sounds.
  40276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40277. */
  40278. rolloffFactor?: number;
  40279. /**
  40280. * Define the reference distance the sound should be heard perfectly.
  40281. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40282. */
  40283. refDistance?: number;
  40284. /**
  40285. * Define the distance attenuation model the sound will follow.
  40286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40287. */
  40288. distanceModel?: string;
  40289. /**
  40290. * Defines the playback speed (1 by default)
  40291. */
  40292. playbackRate?: number;
  40293. /**
  40294. * Defines if the sound is from a streaming source
  40295. */
  40296. streaming?: boolean;
  40297. /**
  40298. * Defines an optional length (in seconds) inside the sound file
  40299. */
  40300. length?: number;
  40301. /**
  40302. * Defines an optional offset (in seconds) inside the sound file
  40303. */
  40304. offset?: number;
  40305. /**
  40306. * If true, URLs will not be required to state the audio file codec to use.
  40307. */
  40308. skipCodecCheck?: boolean;
  40309. }
  40310. /**
  40311. * Defines a sound that can be played in the application.
  40312. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40314. */
  40315. export class Sound {
  40316. /**
  40317. * The name of the sound in the scene.
  40318. */
  40319. name: string;
  40320. /**
  40321. * Does the sound autoplay once loaded.
  40322. */
  40323. autoplay: boolean;
  40324. /**
  40325. * Does the sound loop after it finishes playing once.
  40326. */
  40327. loop: boolean;
  40328. /**
  40329. * Does the sound use a custom attenuation curve to simulate the falloff
  40330. * happening when the source gets further away from the camera.
  40331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40332. */
  40333. useCustomAttenuation: boolean;
  40334. /**
  40335. * The sound track id this sound belongs to.
  40336. */
  40337. soundTrackId: number;
  40338. /**
  40339. * Is this sound currently played.
  40340. */
  40341. isPlaying: boolean;
  40342. /**
  40343. * Is this sound currently paused.
  40344. */
  40345. isPaused: boolean;
  40346. /**
  40347. * Does this sound enables spatial sound.
  40348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40349. */
  40350. spatialSound: boolean;
  40351. /**
  40352. * Define the reference distance the sound should be heard perfectly.
  40353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40354. */
  40355. refDistance: number;
  40356. /**
  40357. * Define the roll off factor of spatial sounds.
  40358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40359. */
  40360. rolloffFactor: number;
  40361. /**
  40362. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40364. */
  40365. maxDistance: number;
  40366. /**
  40367. * Define the distance attenuation model the sound will follow.
  40368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40369. */
  40370. distanceModel: string;
  40371. /**
  40372. * @hidden
  40373. * Back Compat
  40374. **/
  40375. onended: () => any;
  40376. /**
  40377. * Gets or sets an object used to store user defined information for the sound.
  40378. */
  40379. metadata: any;
  40380. /**
  40381. * Observable event when the current playing sound finishes.
  40382. */
  40383. onEndedObservable: Observable<Sound>;
  40384. private _panningModel;
  40385. private _playbackRate;
  40386. private _streaming;
  40387. private _startTime;
  40388. private _startOffset;
  40389. private _position;
  40390. /** @hidden */
  40391. _positionInEmitterSpace: boolean;
  40392. private _localDirection;
  40393. private _volume;
  40394. private _isReadyToPlay;
  40395. private _isDirectional;
  40396. private _readyToPlayCallback;
  40397. private _audioBuffer;
  40398. private _soundSource;
  40399. private _streamingSource;
  40400. private _soundPanner;
  40401. private _soundGain;
  40402. private _inputAudioNode;
  40403. private _outputAudioNode;
  40404. private _coneInnerAngle;
  40405. private _coneOuterAngle;
  40406. private _coneOuterGain;
  40407. private _scene;
  40408. private _connectedTransformNode;
  40409. private _customAttenuationFunction;
  40410. private _registerFunc;
  40411. private _isOutputConnected;
  40412. private _htmlAudioElement;
  40413. private _urlType;
  40414. private _length?;
  40415. private _offset?;
  40416. /** @hidden */
  40417. static _SceneComponentInitialization: (scene: Scene) => void;
  40418. /**
  40419. * Create a sound and attach it to a scene
  40420. * @param name Name of your sound
  40421. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40422. * @param scene defines the scene the sound belongs to
  40423. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40424. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40425. */
  40426. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40427. /**
  40428. * Release the sound and its associated resources
  40429. */
  40430. dispose(): void;
  40431. /**
  40432. * Gets if the sounds is ready to be played or not.
  40433. * @returns true if ready, otherwise false
  40434. */
  40435. isReady(): boolean;
  40436. private _soundLoaded;
  40437. /**
  40438. * Sets the data of the sound from an audiobuffer
  40439. * @param audioBuffer The audioBuffer containing the data
  40440. */
  40441. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40442. /**
  40443. * Updates the current sounds options such as maxdistance, loop...
  40444. * @param options A JSON object containing values named as the object properties
  40445. */
  40446. updateOptions(options: ISoundOptions): void;
  40447. private _createSpatialParameters;
  40448. private _updateSpatialParameters;
  40449. /**
  40450. * Switch the panning model to HRTF:
  40451. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40452. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40453. */
  40454. switchPanningModelToHRTF(): void;
  40455. /**
  40456. * Switch the panning model to Equal Power:
  40457. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40459. */
  40460. switchPanningModelToEqualPower(): void;
  40461. private _switchPanningModel;
  40462. /**
  40463. * Connect this sound to a sound track audio node like gain...
  40464. * @param soundTrackAudioNode the sound track audio node to connect to
  40465. */
  40466. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40467. /**
  40468. * Transform this sound into a directional source
  40469. * @param coneInnerAngle Size of the inner cone in degree
  40470. * @param coneOuterAngle Size of the outer cone in degree
  40471. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40472. */
  40473. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40474. /**
  40475. * Gets or sets the inner angle for the directional cone.
  40476. */
  40477. get directionalConeInnerAngle(): number;
  40478. /**
  40479. * Gets or sets the inner angle for the directional cone.
  40480. */
  40481. set directionalConeInnerAngle(value: number);
  40482. /**
  40483. * Gets or sets the outer angle for the directional cone.
  40484. */
  40485. get directionalConeOuterAngle(): number;
  40486. /**
  40487. * Gets or sets the outer angle for the directional cone.
  40488. */
  40489. set directionalConeOuterAngle(value: number);
  40490. /**
  40491. * Sets the position of the emitter if spatial sound is enabled
  40492. * @param newPosition Defines the new posisiton
  40493. */
  40494. setPosition(newPosition: Vector3): void;
  40495. /**
  40496. * Sets the local direction of the emitter if spatial sound is enabled
  40497. * @param newLocalDirection Defines the new local direction
  40498. */
  40499. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40500. private _updateDirection;
  40501. /** @hidden */
  40502. updateDistanceFromListener(): void;
  40503. /**
  40504. * Sets a new custom attenuation function for the sound.
  40505. * @param callback Defines the function used for the attenuation
  40506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40507. */
  40508. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40509. /**
  40510. * Play the sound
  40511. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40512. * @param offset (optional) Start the sound at a specific time in seconds
  40513. * @param length (optional) Sound duration (in seconds)
  40514. */
  40515. play(time?: number, offset?: number, length?: number): void;
  40516. private _onended;
  40517. /**
  40518. * Stop the sound
  40519. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40520. */
  40521. stop(time?: number): void;
  40522. /**
  40523. * Put the sound in pause
  40524. */
  40525. pause(): void;
  40526. /**
  40527. * Sets a dedicated volume for this sounds
  40528. * @param newVolume Define the new volume of the sound
  40529. * @param time Define time for gradual change to new volume
  40530. */
  40531. setVolume(newVolume: number, time?: number): void;
  40532. /**
  40533. * Set the sound play back rate
  40534. * @param newPlaybackRate Define the playback rate the sound should be played at
  40535. */
  40536. setPlaybackRate(newPlaybackRate: number): void;
  40537. /**
  40538. * Gets the volume of the sound.
  40539. * @returns the volume of the sound
  40540. */
  40541. getVolume(): number;
  40542. /**
  40543. * Attach the sound to a dedicated mesh
  40544. * @param transformNode The transform node to connect the sound with
  40545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40546. */
  40547. attachToMesh(transformNode: TransformNode): void;
  40548. /**
  40549. * Detach the sound from the previously attached mesh
  40550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40551. */
  40552. detachFromMesh(): void;
  40553. private _onRegisterAfterWorldMatrixUpdate;
  40554. /**
  40555. * Clone the current sound in the scene.
  40556. * @returns the new sound clone
  40557. */
  40558. clone(): Nullable<Sound>;
  40559. /**
  40560. * Gets the current underlying audio buffer containing the data
  40561. * @returns the audio buffer
  40562. */
  40563. getAudioBuffer(): Nullable<AudioBuffer>;
  40564. /**
  40565. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40566. * @returns the source node
  40567. */
  40568. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40569. /**
  40570. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40571. * @returns the gain node
  40572. */
  40573. getSoundGain(): Nullable<GainNode>;
  40574. /**
  40575. * Serializes the Sound in a JSON representation
  40576. * @returns the JSON representation of the sound
  40577. */
  40578. serialize(): any;
  40579. /**
  40580. * Parse a JSON representation of a sound to innstantiate in a given scene
  40581. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40582. * @param scene Define the scene the new parsed sound should be created in
  40583. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40584. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40585. * @returns the newly parsed sound
  40586. */
  40587. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40588. }
  40589. }
  40590. declare module BABYLON {
  40591. /**
  40592. * This defines an action helpful to play a defined sound on a triggered action.
  40593. */
  40594. export class PlaySoundAction extends Action {
  40595. private _sound;
  40596. /**
  40597. * Instantiate the action
  40598. * @param triggerOptions defines the trigger options
  40599. * @param sound defines the sound to play
  40600. * @param condition defines the trigger related conditions
  40601. */
  40602. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40603. /** @hidden */
  40604. _prepare(): void;
  40605. /**
  40606. * Execute the action and play the sound.
  40607. */
  40608. execute(): void;
  40609. /**
  40610. * Serializes the actions and its related information.
  40611. * @param parent defines the object to serialize in
  40612. * @returns the serialized object
  40613. */
  40614. serialize(parent: any): any;
  40615. }
  40616. /**
  40617. * This defines an action helpful to stop a defined sound on a triggered action.
  40618. */
  40619. export class StopSoundAction extends Action {
  40620. private _sound;
  40621. /**
  40622. * Instantiate the action
  40623. * @param triggerOptions defines the trigger options
  40624. * @param sound defines the sound to stop
  40625. * @param condition defines the trigger related conditions
  40626. */
  40627. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40628. /** @hidden */
  40629. _prepare(): void;
  40630. /**
  40631. * Execute the action and stop the sound.
  40632. */
  40633. execute(): void;
  40634. /**
  40635. * Serializes the actions and its related information.
  40636. * @param parent defines the object to serialize in
  40637. * @returns the serialized object
  40638. */
  40639. serialize(parent: any): any;
  40640. }
  40641. }
  40642. declare module BABYLON {
  40643. /**
  40644. * This defines an action responsible to change the value of a property
  40645. * by interpolating between its current value and the newly set one once triggered.
  40646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40647. */
  40648. export class InterpolateValueAction extends Action {
  40649. /**
  40650. * Defines the path of the property where the value should be interpolated
  40651. */
  40652. propertyPath: string;
  40653. /**
  40654. * Defines the target value at the end of the interpolation.
  40655. */
  40656. value: any;
  40657. /**
  40658. * Defines the time it will take for the property to interpolate to the value.
  40659. */
  40660. duration: number;
  40661. /**
  40662. * Defines if the other scene animations should be stopped when the action has been triggered
  40663. */
  40664. stopOtherAnimations?: boolean;
  40665. /**
  40666. * Defines a callback raised once the interpolation animation has been done.
  40667. */
  40668. onInterpolationDone?: () => void;
  40669. /**
  40670. * Observable triggered once the interpolation animation has been done.
  40671. */
  40672. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40673. private _target;
  40674. private _effectiveTarget;
  40675. private _property;
  40676. /**
  40677. * Instantiate the action
  40678. * @param triggerOptions defines the trigger options
  40679. * @param target defines the object containing the value to interpolate
  40680. * @param propertyPath defines the path to the property in the target object
  40681. * @param value defines the target value at the end of the interpolation
  40682. * @param duration deines the time it will take for the property to interpolate to the value.
  40683. * @param condition defines the trigger related conditions
  40684. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40685. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40686. */
  40687. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40688. /** @hidden */
  40689. _prepare(): void;
  40690. /**
  40691. * Execute the action starts the value interpolation.
  40692. */
  40693. execute(): void;
  40694. /**
  40695. * Serializes the actions and its related information.
  40696. * @param parent defines the object to serialize in
  40697. * @returns the serialized object
  40698. */
  40699. serialize(parent: any): any;
  40700. }
  40701. }
  40702. declare module BABYLON {
  40703. /**
  40704. * Options allowed during the creation of a sound track.
  40705. */
  40706. export interface ISoundTrackOptions {
  40707. /**
  40708. * The volume the sound track should take during creation
  40709. */
  40710. volume?: number;
  40711. /**
  40712. * Define if the sound track is the main sound track of the scene
  40713. */
  40714. mainTrack?: boolean;
  40715. }
  40716. /**
  40717. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40718. * It will be also used in a future release to apply effects on a specific track.
  40719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40720. */
  40721. export class SoundTrack {
  40722. /**
  40723. * The unique identifier of the sound track in the scene.
  40724. */
  40725. id: number;
  40726. /**
  40727. * The list of sounds included in the sound track.
  40728. */
  40729. soundCollection: Array<Sound>;
  40730. private _outputAudioNode;
  40731. private _scene;
  40732. private _connectedAnalyser;
  40733. private _options;
  40734. private _isInitialized;
  40735. /**
  40736. * Creates a new sound track.
  40737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40738. * @param scene Define the scene the sound track belongs to
  40739. * @param options
  40740. */
  40741. constructor(scene: Scene, options?: ISoundTrackOptions);
  40742. private _initializeSoundTrackAudioGraph;
  40743. /**
  40744. * Release the sound track and its associated resources
  40745. */
  40746. dispose(): void;
  40747. /**
  40748. * Adds a sound to this sound track
  40749. * @param sound define the cound to add
  40750. * @ignoreNaming
  40751. */
  40752. AddSound(sound: Sound): void;
  40753. /**
  40754. * Removes a sound to this sound track
  40755. * @param sound define the cound to remove
  40756. * @ignoreNaming
  40757. */
  40758. RemoveSound(sound: Sound): void;
  40759. /**
  40760. * Set a global volume for the full sound track.
  40761. * @param newVolume Define the new volume of the sound track
  40762. */
  40763. setVolume(newVolume: number): void;
  40764. /**
  40765. * Switch the panning model to HRTF:
  40766. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40768. */
  40769. switchPanningModelToHRTF(): void;
  40770. /**
  40771. * Switch the panning model to Equal Power:
  40772. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40774. */
  40775. switchPanningModelToEqualPower(): void;
  40776. /**
  40777. * Connect the sound track to an audio analyser allowing some amazing
  40778. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40779. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40780. * @param analyser The analyser to connect to the engine
  40781. */
  40782. connectToAnalyser(analyser: Analyser): void;
  40783. }
  40784. }
  40785. declare module BABYLON {
  40786. interface AbstractScene {
  40787. /**
  40788. * The list of sounds used in the scene.
  40789. */
  40790. sounds: Nullable<Array<Sound>>;
  40791. }
  40792. interface Scene {
  40793. /**
  40794. * @hidden
  40795. * Backing field
  40796. */
  40797. _mainSoundTrack: SoundTrack;
  40798. /**
  40799. * The main sound track played by the scene.
  40800. * It cotains your primary collection of sounds.
  40801. */
  40802. mainSoundTrack: SoundTrack;
  40803. /**
  40804. * The list of sound tracks added to the scene
  40805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40806. */
  40807. soundTracks: Nullable<Array<SoundTrack>>;
  40808. /**
  40809. * Gets a sound using a given name
  40810. * @param name defines the name to search for
  40811. * @return the found sound or null if not found at all.
  40812. */
  40813. getSoundByName(name: string): Nullable<Sound>;
  40814. /**
  40815. * Gets or sets if audio support is enabled
  40816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40817. */
  40818. audioEnabled: boolean;
  40819. /**
  40820. * Gets or sets if audio will be output to headphones
  40821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40822. */
  40823. headphone: boolean;
  40824. /**
  40825. * Gets or sets custom audio listener position provider
  40826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40827. */
  40828. audioListenerPositionProvider: Nullable<() => Vector3>;
  40829. /**
  40830. * Gets or sets a refresh rate when using 3D audio positioning
  40831. */
  40832. audioPositioningRefreshRate: number;
  40833. }
  40834. /**
  40835. * Defines the sound scene component responsible to manage any sounds
  40836. * in a given scene.
  40837. */
  40838. export class AudioSceneComponent implements ISceneSerializableComponent {
  40839. /**
  40840. * The component name helpfull to identify the component in the list of scene components.
  40841. */
  40842. readonly name: string;
  40843. /**
  40844. * The scene the component belongs to.
  40845. */
  40846. scene: Scene;
  40847. private _audioEnabled;
  40848. /**
  40849. * Gets whether audio is enabled or not.
  40850. * Please use related enable/disable method to switch state.
  40851. */
  40852. get audioEnabled(): boolean;
  40853. private _headphone;
  40854. /**
  40855. * Gets whether audio is outputing to headphone or not.
  40856. * Please use the according Switch methods to change output.
  40857. */
  40858. get headphone(): boolean;
  40859. /**
  40860. * Gets or sets a refresh rate when using 3D audio positioning
  40861. */
  40862. audioPositioningRefreshRate: number;
  40863. private _audioListenerPositionProvider;
  40864. /**
  40865. * Gets the current audio listener position provider
  40866. */
  40867. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  40868. /**
  40869. * Sets a custom listener position for all sounds in the scene
  40870. * By default, this is the position of the first active camera
  40871. */
  40872. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  40873. /**
  40874. * Creates a new instance of the component for the given scene
  40875. * @param scene Defines the scene to register the component in
  40876. */
  40877. constructor(scene: Scene);
  40878. /**
  40879. * Registers the component in a given scene
  40880. */
  40881. register(): void;
  40882. /**
  40883. * Rebuilds the elements related to this component in case of
  40884. * context lost for instance.
  40885. */
  40886. rebuild(): void;
  40887. /**
  40888. * Serializes the component data to the specified json object
  40889. * @param serializationObject The object to serialize to
  40890. */
  40891. serialize(serializationObject: any): void;
  40892. /**
  40893. * Adds all the elements from the container to the scene
  40894. * @param container the container holding the elements
  40895. */
  40896. addFromContainer(container: AbstractScene): void;
  40897. /**
  40898. * Removes all the elements in the container from the scene
  40899. * @param container contains the elements to remove
  40900. * @param dispose if the removed element should be disposed (default: false)
  40901. */
  40902. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  40903. /**
  40904. * Disposes the component and the associated ressources.
  40905. */
  40906. dispose(): void;
  40907. /**
  40908. * Disables audio in the associated scene.
  40909. */
  40910. disableAudio(): void;
  40911. /**
  40912. * Enables audio in the associated scene.
  40913. */
  40914. enableAudio(): void;
  40915. /**
  40916. * Switch audio to headphone output.
  40917. */
  40918. switchAudioModeForHeadphones(): void;
  40919. /**
  40920. * Switch audio to normal speakers.
  40921. */
  40922. switchAudioModeForNormalSpeakers(): void;
  40923. private _cachedCameraDirection;
  40924. private _cachedCameraPosition;
  40925. private _lastCheck;
  40926. private _afterRender;
  40927. }
  40928. }
  40929. declare module BABYLON {
  40930. /**
  40931. * Wraps one or more Sound objects and selects one with random weight for playback.
  40932. */
  40933. export class WeightedSound {
  40934. /** When true a Sound will be selected and played when the current playing Sound completes. */
  40935. loop: boolean;
  40936. private _coneInnerAngle;
  40937. private _coneOuterAngle;
  40938. private _volume;
  40939. /** A Sound is currently playing. */
  40940. isPlaying: boolean;
  40941. /** A Sound is currently paused. */
  40942. isPaused: boolean;
  40943. private _sounds;
  40944. private _weights;
  40945. private _currentIndex?;
  40946. /**
  40947. * Creates a new WeightedSound from the list of sounds given.
  40948. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  40949. * @param sounds Array of Sounds that will be selected from.
  40950. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  40951. */
  40952. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  40953. /**
  40954. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  40955. */
  40956. get directionalConeInnerAngle(): number;
  40957. /**
  40958. * The size of cone in degress for a directional sound in which there will be no attenuation.
  40959. */
  40960. set directionalConeInnerAngle(value: number);
  40961. /**
  40962. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40963. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40964. */
  40965. get directionalConeOuterAngle(): number;
  40966. /**
  40967. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  40968. * Listener angles between innerAngle and outerAngle will falloff linearly.
  40969. */
  40970. set directionalConeOuterAngle(value: number);
  40971. /**
  40972. * Playback volume.
  40973. */
  40974. get volume(): number;
  40975. /**
  40976. * Playback volume.
  40977. */
  40978. set volume(value: number);
  40979. private _onended;
  40980. /**
  40981. * Suspend playback
  40982. */
  40983. pause(): void;
  40984. /**
  40985. * Stop playback
  40986. */
  40987. stop(): void;
  40988. /**
  40989. * Start playback.
  40990. * @param startOffset Position the clip head at a specific time in seconds.
  40991. */
  40992. play(startOffset?: number): void;
  40993. }
  40994. }
  40995. declare module BABYLON {
  40996. /**
  40997. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40998. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40999. */
  41000. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41001. /**
  41002. * Gets the name of the behavior.
  41003. */
  41004. get name(): string;
  41005. /**
  41006. * The easing function used by animations
  41007. */
  41008. static EasingFunction: BackEase;
  41009. /**
  41010. * The easing mode used by animations
  41011. */
  41012. static EasingMode: number;
  41013. /**
  41014. * The duration of the animation, in milliseconds
  41015. */
  41016. transitionDuration: number;
  41017. /**
  41018. * Length of the distance animated by the transition when lower radius is reached
  41019. */
  41020. lowerRadiusTransitionRange: number;
  41021. /**
  41022. * Length of the distance animated by the transition when upper radius is reached
  41023. */
  41024. upperRadiusTransitionRange: number;
  41025. private _autoTransitionRange;
  41026. /**
  41027. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41028. */
  41029. get autoTransitionRange(): boolean;
  41030. /**
  41031. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41032. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41033. */
  41034. set autoTransitionRange(value: boolean);
  41035. private _attachedCamera;
  41036. private _onAfterCheckInputsObserver;
  41037. private _onMeshTargetChangedObserver;
  41038. /**
  41039. * Initializes the behavior.
  41040. */
  41041. init(): void;
  41042. /**
  41043. * Attaches the behavior to its arc rotate camera.
  41044. * @param camera Defines the camera to attach the behavior to
  41045. */
  41046. attach(camera: ArcRotateCamera): void;
  41047. /**
  41048. * Detaches the behavior from its current arc rotate camera.
  41049. */
  41050. detach(): void;
  41051. private _radiusIsAnimating;
  41052. private _radiusBounceTransition;
  41053. private _animatables;
  41054. private _cachedWheelPrecision;
  41055. /**
  41056. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41057. * @param radiusLimit The limit to check against.
  41058. * @return Bool to indicate if at limit.
  41059. */
  41060. private _isRadiusAtLimit;
  41061. /**
  41062. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41063. * @param radiusDelta The delta by which to animate to. Can be negative.
  41064. */
  41065. private _applyBoundRadiusAnimation;
  41066. /**
  41067. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41068. */
  41069. protected _clearAnimationLocks(): void;
  41070. /**
  41071. * Stops and removes all animations that have been applied to the camera
  41072. */
  41073. stopAllAnimations(): void;
  41074. }
  41075. }
  41076. declare module BABYLON {
  41077. /**
  41078. * 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.
  41079. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41080. */
  41081. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41082. /**
  41083. * Gets the name of the behavior.
  41084. */
  41085. get name(): string;
  41086. private _mode;
  41087. private _radiusScale;
  41088. private _positionScale;
  41089. private _defaultElevation;
  41090. private _elevationReturnTime;
  41091. private _elevationReturnWaitTime;
  41092. private _zoomStopsAnimation;
  41093. private _framingTime;
  41094. /**
  41095. * The easing function used by animations
  41096. */
  41097. static EasingFunction: ExponentialEase;
  41098. /**
  41099. * The easing mode used by animations
  41100. */
  41101. static EasingMode: number;
  41102. /**
  41103. * Sets the current mode used by the behavior
  41104. */
  41105. set mode(mode: number);
  41106. /**
  41107. * Gets current mode used by the behavior.
  41108. */
  41109. get mode(): number;
  41110. /**
  41111. * Sets the scale applied to the radius (1 by default)
  41112. */
  41113. set radiusScale(radius: number);
  41114. /**
  41115. * Gets the scale applied to the radius
  41116. */
  41117. get radiusScale(): number;
  41118. /**
  41119. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41120. */
  41121. set positionScale(scale: number);
  41122. /**
  41123. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41124. */
  41125. get positionScale(): number;
  41126. /**
  41127. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41128. * behaviour is triggered, in radians.
  41129. */
  41130. set defaultElevation(elevation: number);
  41131. /**
  41132. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41133. * behaviour is triggered, in radians.
  41134. */
  41135. get defaultElevation(): number;
  41136. /**
  41137. * Sets the time (in milliseconds) taken to return to the default beta position.
  41138. * Negative value indicates camera should not return to default.
  41139. */
  41140. set elevationReturnTime(speed: number);
  41141. /**
  41142. * Gets the time (in milliseconds) taken to return to the default beta position.
  41143. * Negative value indicates camera should not return to default.
  41144. */
  41145. get elevationReturnTime(): number;
  41146. /**
  41147. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41148. */
  41149. set elevationReturnWaitTime(time: number);
  41150. /**
  41151. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41152. */
  41153. get elevationReturnWaitTime(): number;
  41154. /**
  41155. * Sets the flag that indicates if user zooming should stop animation.
  41156. */
  41157. set zoomStopsAnimation(flag: boolean);
  41158. /**
  41159. * Gets the flag that indicates if user zooming should stop animation.
  41160. */
  41161. get zoomStopsAnimation(): boolean;
  41162. /**
  41163. * Sets the transition time when framing the mesh, in milliseconds
  41164. */
  41165. set framingTime(time: number);
  41166. /**
  41167. * Gets the transition time when framing the mesh, in milliseconds
  41168. */
  41169. get framingTime(): number;
  41170. /**
  41171. * Define if the behavior should automatically change the configured
  41172. * camera limits and sensibilities.
  41173. */
  41174. autoCorrectCameraLimitsAndSensibility: boolean;
  41175. private _onPrePointerObservableObserver;
  41176. private _onAfterCheckInputsObserver;
  41177. private _onMeshTargetChangedObserver;
  41178. private _attachedCamera;
  41179. private _isPointerDown;
  41180. private _lastInteractionTime;
  41181. /**
  41182. * Initializes the behavior.
  41183. */
  41184. init(): void;
  41185. /**
  41186. * Attaches the behavior to its arc rotate camera.
  41187. * @param camera Defines the camera to attach the behavior to
  41188. */
  41189. attach(camera: ArcRotateCamera): void;
  41190. /**
  41191. * Detaches the behavior from its current arc rotate camera.
  41192. */
  41193. detach(): void;
  41194. private _animatables;
  41195. private _betaIsAnimating;
  41196. private _betaTransition;
  41197. private _radiusTransition;
  41198. private _vectorTransition;
  41199. /**
  41200. * Targets the given mesh and updates zoom level accordingly.
  41201. * @param mesh The mesh to target.
  41202. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41203. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41204. */
  41205. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41206. /**
  41207. * Targets the given mesh with its children and updates zoom level accordingly.
  41208. * @param mesh The mesh to target.
  41209. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41210. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41211. */
  41212. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41213. /**
  41214. * Targets the given meshes with their children and updates zoom level accordingly.
  41215. * @param meshes The mesh to target.
  41216. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41217. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41218. */
  41219. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41220. /**
  41221. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41222. * @param minimumWorld Determines the smaller position of the bounding box extend
  41223. * @param maximumWorld Determines the bigger position of the bounding box extend
  41224. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41225. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41226. */
  41227. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41228. /**
  41229. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41230. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41231. * frustum width.
  41232. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41233. * to fully enclose the mesh in the viewing frustum.
  41234. */
  41235. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41236. /**
  41237. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41238. * is automatically returned to its default position (expected to be above ground plane).
  41239. */
  41240. private _maintainCameraAboveGround;
  41241. /**
  41242. * Returns the frustum slope based on the canvas ratio and camera FOV
  41243. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41244. */
  41245. private _getFrustumSlope;
  41246. /**
  41247. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41248. */
  41249. private _clearAnimationLocks;
  41250. /**
  41251. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41252. */
  41253. private _applyUserInteraction;
  41254. /**
  41255. * Stops and removes all animations that have been applied to the camera
  41256. */
  41257. stopAllAnimations(): void;
  41258. /**
  41259. * Gets a value indicating if the user is moving the camera
  41260. */
  41261. get isUserIsMoving(): boolean;
  41262. /**
  41263. * The camera can move all the way towards the mesh.
  41264. */
  41265. static IgnoreBoundsSizeMode: number;
  41266. /**
  41267. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41268. */
  41269. static FitFrustumSidesMode: number;
  41270. }
  41271. }
  41272. declare module BABYLON {
  41273. /**
  41274. * Base class for Camera Pointer Inputs.
  41275. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41276. * for example usage.
  41277. */
  41278. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41279. /**
  41280. * Defines the camera the input is attached to.
  41281. */
  41282. abstract camera: Camera;
  41283. /**
  41284. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41285. */
  41286. protected _altKey: boolean;
  41287. protected _ctrlKey: boolean;
  41288. protected _metaKey: boolean;
  41289. protected _shiftKey: boolean;
  41290. /**
  41291. * Which mouse buttons were pressed at time of last mouse event.
  41292. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41293. */
  41294. protected _buttonsPressed: number;
  41295. /**
  41296. * Defines the buttons associated with the input to handle camera move.
  41297. */
  41298. buttons: number[];
  41299. /**
  41300. * Attach the input controls to a specific dom element to get the input from.
  41301. * @param element Defines the element the controls should be listened from
  41302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41303. */
  41304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41305. /**
  41306. * Detach the current controls from the specified dom element.
  41307. * @param element Defines the element to stop listening the inputs from
  41308. */
  41309. detachControl(element: Nullable<HTMLElement>): void;
  41310. /**
  41311. * Gets the class name of the current input.
  41312. * @returns the class name
  41313. */
  41314. getClassName(): string;
  41315. /**
  41316. * Get the friendly name associated with the input class.
  41317. * @returns the input friendly name
  41318. */
  41319. getSimpleName(): string;
  41320. /**
  41321. * Called on pointer POINTERDOUBLETAP event.
  41322. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41323. */
  41324. protected onDoubleTap(type: string): void;
  41325. /**
  41326. * Called on pointer POINTERMOVE event if only a single touch is active.
  41327. * Override this method to provide functionality.
  41328. */
  41329. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41330. /**
  41331. * Called on pointer POINTERMOVE event if multiple touches are active.
  41332. * Override this method to provide functionality.
  41333. */
  41334. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41335. /**
  41336. * Called on JS contextmenu event.
  41337. * Override this method to provide functionality.
  41338. */
  41339. protected onContextMenu(evt: PointerEvent): void;
  41340. /**
  41341. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41342. * press.
  41343. * Override this method to provide functionality.
  41344. */
  41345. protected onButtonDown(evt: PointerEvent): void;
  41346. /**
  41347. * Called each time a new POINTERUP event occurs. Ie, for each button
  41348. * release.
  41349. * Override this method to provide functionality.
  41350. */
  41351. protected onButtonUp(evt: PointerEvent): void;
  41352. /**
  41353. * Called when window becomes inactive.
  41354. * Override this method to provide functionality.
  41355. */
  41356. protected onLostFocus(): void;
  41357. private _pointerInput;
  41358. private _observer;
  41359. private _onLostFocus;
  41360. private pointA;
  41361. private pointB;
  41362. }
  41363. }
  41364. declare module BABYLON {
  41365. /**
  41366. * Manage the pointers inputs to control an arc rotate camera.
  41367. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41368. */
  41369. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41370. /**
  41371. * Defines the camera the input is attached to.
  41372. */
  41373. camera: ArcRotateCamera;
  41374. /**
  41375. * Gets the class name of the current input.
  41376. * @returns the class name
  41377. */
  41378. getClassName(): string;
  41379. /**
  41380. * Defines the buttons associated with the input to handle camera move.
  41381. */
  41382. buttons: number[];
  41383. /**
  41384. * Defines the pointer angular sensibility along the X axis or how fast is
  41385. * the camera rotating.
  41386. */
  41387. angularSensibilityX: number;
  41388. /**
  41389. * Defines the pointer angular sensibility along the Y axis or how fast is
  41390. * the camera rotating.
  41391. */
  41392. angularSensibilityY: number;
  41393. /**
  41394. * Defines the pointer pinch precision or how fast is the camera zooming.
  41395. */
  41396. pinchPrecision: number;
  41397. /**
  41398. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41399. * from 0.
  41400. * It defines the percentage of current camera.radius to use as delta when
  41401. * pinch zoom is used.
  41402. */
  41403. pinchDeltaPercentage: number;
  41404. /**
  41405. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41406. * that any object in the plane at the camera's target point will scale
  41407. * perfectly with finger motion.
  41408. * Overrides pinchDeltaPercentage and pinchPrecision.
  41409. */
  41410. useNaturalPinchZoom: boolean;
  41411. /**
  41412. * Defines the pointer panning sensibility or how fast is the camera moving.
  41413. */
  41414. panningSensibility: number;
  41415. /**
  41416. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41417. */
  41418. multiTouchPanning: boolean;
  41419. /**
  41420. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41421. * zoom (pinch) through multitouch.
  41422. */
  41423. multiTouchPanAndZoom: boolean;
  41424. /**
  41425. * Revers pinch action direction.
  41426. */
  41427. pinchInwards: boolean;
  41428. private _isPanClick;
  41429. private _twoFingerActivityCount;
  41430. private _isPinching;
  41431. /**
  41432. * Called on pointer POINTERMOVE event if only a single touch is active.
  41433. */
  41434. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41435. /**
  41436. * Called on pointer POINTERDOUBLETAP event.
  41437. */
  41438. protected onDoubleTap(type: string): void;
  41439. /**
  41440. * Called on pointer POINTERMOVE event if multiple touches are active.
  41441. */
  41442. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41443. /**
  41444. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41445. * press.
  41446. */
  41447. protected onButtonDown(evt: PointerEvent): void;
  41448. /**
  41449. * Called each time a new POINTERUP event occurs. Ie, for each button
  41450. * release.
  41451. */
  41452. protected onButtonUp(evt: PointerEvent): void;
  41453. /**
  41454. * Called when window becomes inactive.
  41455. */
  41456. protected onLostFocus(): void;
  41457. }
  41458. }
  41459. declare module BABYLON {
  41460. /**
  41461. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41462. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41463. */
  41464. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41465. /**
  41466. * Defines the camera the input is attached to.
  41467. */
  41468. camera: ArcRotateCamera;
  41469. /**
  41470. * Defines the list of key codes associated with the up action (increase alpha)
  41471. */
  41472. keysUp: number[];
  41473. /**
  41474. * Defines the list of key codes associated with the down action (decrease alpha)
  41475. */
  41476. keysDown: number[];
  41477. /**
  41478. * Defines the list of key codes associated with the left action (increase beta)
  41479. */
  41480. keysLeft: number[];
  41481. /**
  41482. * Defines the list of key codes associated with the right action (decrease beta)
  41483. */
  41484. keysRight: number[];
  41485. /**
  41486. * Defines the list of key codes associated with the reset action.
  41487. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41488. */
  41489. keysReset: number[];
  41490. /**
  41491. * Defines the panning sensibility of the inputs.
  41492. * (How fast is the camera panning)
  41493. */
  41494. panningSensibility: number;
  41495. /**
  41496. * Defines the zooming sensibility of the inputs.
  41497. * (How fast is the camera zooming)
  41498. */
  41499. zoomingSensibility: number;
  41500. /**
  41501. * Defines whether maintaining the alt key down switch the movement mode from
  41502. * orientation to zoom.
  41503. */
  41504. useAltToZoom: boolean;
  41505. /**
  41506. * Rotation speed of the camera
  41507. */
  41508. angularSpeed: number;
  41509. private _keys;
  41510. private _ctrlPressed;
  41511. private _altPressed;
  41512. private _onCanvasBlurObserver;
  41513. private _onKeyboardObserver;
  41514. private _engine;
  41515. private _scene;
  41516. /**
  41517. * Attach the input controls to a specific dom element to get the input from.
  41518. * @param element Defines the element the controls should be listened from
  41519. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41520. */
  41521. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41522. /**
  41523. * Detach the current controls from the specified dom element.
  41524. * @param element Defines the element to stop listening the inputs from
  41525. */
  41526. detachControl(element: Nullable<HTMLElement>): void;
  41527. /**
  41528. * Update the current camera state depending on the inputs that have been used this frame.
  41529. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41530. */
  41531. checkInputs(): void;
  41532. /**
  41533. * Gets the class name of the current intput.
  41534. * @returns the class name
  41535. */
  41536. getClassName(): string;
  41537. /**
  41538. * Get the friendly name associated with the input class.
  41539. * @returns the input friendly name
  41540. */
  41541. getSimpleName(): string;
  41542. }
  41543. }
  41544. declare module BABYLON {
  41545. /**
  41546. * Manage the mouse wheel inputs to control an arc rotate camera.
  41547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41548. */
  41549. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41550. /**
  41551. * Defines the camera the input is attached to.
  41552. */
  41553. camera: ArcRotateCamera;
  41554. /**
  41555. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41556. */
  41557. wheelPrecision: number;
  41558. /**
  41559. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41560. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41561. */
  41562. wheelDeltaPercentage: number;
  41563. private _wheel;
  41564. private _observer;
  41565. private computeDeltaFromMouseWheelLegacyEvent;
  41566. /**
  41567. * Attach the input controls to a specific dom element to get the input from.
  41568. * @param element Defines the element the controls should be listened from
  41569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41570. */
  41571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41572. /**
  41573. * Detach the current controls from the specified dom element.
  41574. * @param element Defines the element to stop listening the inputs from
  41575. */
  41576. detachControl(element: Nullable<HTMLElement>): void;
  41577. /**
  41578. * Gets the class name of the current intput.
  41579. * @returns the class name
  41580. */
  41581. getClassName(): string;
  41582. /**
  41583. * Get the friendly name associated with the input class.
  41584. * @returns the input friendly name
  41585. */
  41586. getSimpleName(): string;
  41587. }
  41588. }
  41589. declare module BABYLON {
  41590. /**
  41591. * Default Inputs manager for the ArcRotateCamera.
  41592. * It groups all the default supported inputs for ease of use.
  41593. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41594. */
  41595. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41596. /**
  41597. * Instantiates a new ArcRotateCameraInputsManager.
  41598. * @param camera Defines the camera the inputs belong to
  41599. */
  41600. constructor(camera: ArcRotateCamera);
  41601. /**
  41602. * Add mouse wheel input support to the input manager.
  41603. * @returns the current input manager
  41604. */
  41605. addMouseWheel(): ArcRotateCameraInputsManager;
  41606. /**
  41607. * Add pointers input support to the input manager.
  41608. * @returns the current input manager
  41609. */
  41610. addPointers(): ArcRotateCameraInputsManager;
  41611. /**
  41612. * Add keyboard input support to the input manager.
  41613. * @returns the current input manager
  41614. */
  41615. addKeyboard(): ArcRotateCameraInputsManager;
  41616. }
  41617. }
  41618. declare module BABYLON {
  41619. /**
  41620. * This represents an orbital type of camera.
  41621. *
  41622. * 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.
  41623. * 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.
  41624. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41625. */
  41626. export class ArcRotateCamera extends TargetCamera {
  41627. /**
  41628. * Defines the rotation angle of the camera along the longitudinal axis.
  41629. */
  41630. alpha: number;
  41631. /**
  41632. * Defines the rotation angle of the camera along the latitudinal axis.
  41633. */
  41634. beta: number;
  41635. /**
  41636. * Defines the radius of the camera from it s target point.
  41637. */
  41638. radius: number;
  41639. protected _target: Vector3;
  41640. protected _targetHost: Nullable<AbstractMesh>;
  41641. /**
  41642. * Defines the target point of the camera.
  41643. * The camera looks towards it form the radius distance.
  41644. */
  41645. get target(): Vector3;
  41646. set target(value: Vector3);
  41647. /**
  41648. * Define the current local position of the camera in the scene
  41649. */
  41650. get position(): Vector3;
  41651. set position(newPosition: Vector3);
  41652. protected _upVector: Vector3;
  41653. protected _upToYMatrix: Matrix;
  41654. protected _YToUpMatrix: Matrix;
  41655. /**
  41656. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41657. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41658. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41659. */
  41660. set upVector(vec: Vector3);
  41661. get upVector(): Vector3;
  41662. /**
  41663. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41664. */
  41665. setMatUp(): void;
  41666. /**
  41667. * Current inertia value on the longitudinal axis.
  41668. * The bigger this number the longer it will take for the camera to stop.
  41669. */
  41670. inertialAlphaOffset: number;
  41671. /**
  41672. * Current inertia value on the latitudinal axis.
  41673. * The bigger this number the longer it will take for the camera to stop.
  41674. */
  41675. inertialBetaOffset: number;
  41676. /**
  41677. * Current inertia value on the radius axis.
  41678. * The bigger this number the longer it will take for the camera to stop.
  41679. */
  41680. inertialRadiusOffset: number;
  41681. /**
  41682. * Minimum allowed angle on the longitudinal axis.
  41683. * This can help limiting how the Camera is able to move in the scene.
  41684. */
  41685. lowerAlphaLimit: Nullable<number>;
  41686. /**
  41687. * Maximum allowed angle on the longitudinal axis.
  41688. * This can help limiting how the Camera is able to move in the scene.
  41689. */
  41690. upperAlphaLimit: Nullable<number>;
  41691. /**
  41692. * Minimum allowed angle on the latitudinal axis.
  41693. * This can help limiting how the Camera is able to move in the scene.
  41694. */
  41695. lowerBetaLimit: number;
  41696. /**
  41697. * Maximum allowed angle on the latitudinal axis.
  41698. * This can help limiting how the Camera is able to move in the scene.
  41699. */
  41700. upperBetaLimit: number;
  41701. /**
  41702. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41703. * This can help limiting how the Camera is able to move in the scene.
  41704. */
  41705. lowerRadiusLimit: Nullable<number>;
  41706. /**
  41707. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41708. * This can help limiting how the Camera is able to move in the scene.
  41709. */
  41710. upperRadiusLimit: Nullable<number>;
  41711. /**
  41712. * Defines the current inertia value used during panning of the camera along the X axis.
  41713. */
  41714. inertialPanningX: number;
  41715. /**
  41716. * Defines the current inertia value used during panning of the camera along the Y axis.
  41717. */
  41718. inertialPanningY: number;
  41719. /**
  41720. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41721. * Basically if your fingers moves away from more than this distance you will be considered
  41722. * in pinch mode.
  41723. */
  41724. pinchToPanMaxDistance: number;
  41725. /**
  41726. * Defines the maximum distance the camera can pan.
  41727. * This could help keeping the cammera always in your scene.
  41728. */
  41729. panningDistanceLimit: Nullable<number>;
  41730. /**
  41731. * Defines the target of the camera before paning.
  41732. */
  41733. panningOriginTarget: Vector3;
  41734. /**
  41735. * Defines the value of the inertia used during panning.
  41736. * 0 would mean stop inertia and one would mean no decelleration at all.
  41737. */
  41738. panningInertia: number;
  41739. /**
  41740. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41741. */
  41742. get angularSensibilityX(): number;
  41743. set angularSensibilityX(value: number);
  41744. /**
  41745. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41746. */
  41747. get angularSensibilityY(): number;
  41748. set angularSensibilityY(value: number);
  41749. /**
  41750. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  41751. */
  41752. get pinchPrecision(): number;
  41753. set pinchPrecision(value: number);
  41754. /**
  41755. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  41756. * It will be used instead of pinchDeltaPrecision if different from 0.
  41757. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41758. */
  41759. get pinchDeltaPercentage(): number;
  41760. set pinchDeltaPercentage(value: number);
  41761. /**
  41762. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  41763. * and pinch delta percentage.
  41764. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41765. * that any object in the plane at the camera's target point will scale
  41766. * perfectly with finger motion.
  41767. */
  41768. get useNaturalPinchZoom(): boolean;
  41769. set useNaturalPinchZoom(value: boolean);
  41770. /**
  41771. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  41772. */
  41773. get panningSensibility(): number;
  41774. set panningSensibility(value: number);
  41775. /**
  41776. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  41777. */
  41778. get keysUp(): number[];
  41779. set keysUp(value: number[]);
  41780. /**
  41781. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  41782. */
  41783. get keysDown(): number[];
  41784. set keysDown(value: number[]);
  41785. /**
  41786. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  41787. */
  41788. get keysLeft(): number[];
  41789. set keysLeft(value: number[]);
  41790. /**
  41791. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  41792. */
  41793. get keysRight(): number[];
  41794. set keysRight(value: number[]);
  41795. /**
  41796. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41797. */
  41798. get wheelPrecision(): number;
  41799. set wheelPrecision(value: number);
  41800. /**
  41801. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  41802. * It will be used instead of pinchDeltaPrecision if different from 0.
  41803. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41804. */
  41805. get wheelDeltaPercentage(): number;
  41806. set wheelDeltaPercentage(value: number);
  41807. /**
  41808. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  41809. */
  41810. zoomOnFactor: number;
  41811. /**
  41812. * Defines a screen offset for the camera position.
  41813. */
  41814. targetScreenOffset: Vector2;
  41815. /**
  41816. * Allows the camera to be completely reversed.
  41817. * If false the camera can not arrive upside down.
  41818. */
  41819. allowUpsideDown: boolean;
  41820. /**
  41821. * Define if double tap/click is used to restore the previously saved state of the camera.
  41822. */
  41823. useInputToRestoreState: boolean;
  41824. /** @hidden */
  41825. _viewMatrix: Matrix;
  41826. /** @hidden */
  41827. _useCtrlForPanning: boolean;
  41828. /** @hidden */
  41829. _panningMouseButton: number;
  41830. /**
  41831. * Defines the input associated to the camera.
  41832. */
  41833. inputs: ArcRotateCameraInputsManager;
  41834. /** @hidden */
  41835. _reset: () => void;
  41836. /**
  41837. * Defines the allowed panning axis.
  41838. */
  41839. panningAxis: Vector3;
  41840. protected _localDirection: Vector3;
  41841. protected _transformedDirection: Vector3;
  41842. private _bouncingBehavior;
  41843. /**
  41844. * Gets the bouncing behavior of the camera if it has been enabled.
  41845. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41846. */
  41847. get bouncingBehavior(): Nullable<BouncingBehavior>;
  41848. /**
  41849. * Defines if the bouncing behavior of the camera is enabled on the camera.
  41850. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41851. */
  41852. get useBouncingBehavior(): boolean;
  41853. set useBouncingBehavior(value: boolean);
  41854. private _framingBehavior;
  41855. /**
  41856. * Gets the framing behavior of the camera if it has been enabled.
  41857. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41858. */
  41859. get framingBehavior(): Nullable<FramingBehavior>;
  41860. /**
  41861. * Defines if the framing behavior of the camera is enabled on the camera.
  41862. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41863. */
  41864. get useFramingBehavior(): boolean;
  41865. set useFramingBehavior(value: boolean);
  41866. private _autoRotationBehavior;
  41867. /**
  41868. * Gets the auto rotation behavior of the camera if it has been enabled.
  41869. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41870. */
  41871. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  41872. /**
  41873. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  41874. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  41875. */
  41876. get useAutoRotationBehavior(): boolean;
  41877. set useAutoRotationBehavior(value: boolean);
  41878. /**
  41879. * Observable triggered when the mesh target has been changed on the camera.
  41880. */
  41881. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  41882. /**
  41883. * Event raised when the camera is colliding with a mesh.
  41884. */
  41885. onCollide: (collidedMesh: AbstractMesh) => void;
  41886. /**
  41887. * Defines whether the camera should check collision with the objects oh the scene.
  41888. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  41889. */
  41890. checkCollisions: boolean;
  41891. /**
  41892. * Defines the collision radius of the camera.
  41893. * This simulates a sphere around the camera.
  41894. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41895. */
  41896. collisionRadius: Vector3;
  41897. protected _collider: Collider;
  41898. protected _previousPosition: Vector3;
  41899. protected _collisionVelocity: Vector3;
  41900. protected _newPosition: Vector3;
  41901. protected _previousAlpha: number;
  41902. protected _previousBeta: number;
  41903. protected _previousRadius: number;
  41904. protected _collisionTriggered: boolean;
  41905. protected _targetBoundingCenter: Nullable<Vector3>;
  41906. private _computationVector;
  41907. /**
  41908. * Instantiates a new ArcRotateCamera in a given scene
  41909. * @param name Defines the name of the camera
  41910. * @param alpha Defines the camera rotation along the logitudinal axis
  41911. * @param beta Defines the camera rotation along the latitudinal axis
  41912. * @param radius Defines the camera distance from its target
  41913. * @param target Defines the camera target
  41914. * @param scene Defines the scene the camera belongs to
  41915. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  41916. */
  41917. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41918. /** @hidden */
  41919. _initCache(): void;
  41920. /** @hidden */
  41921. _updateCache(ignoreParentClass?: boolean): void;
  41922. protected _getTargetPosition(): Vector3;
  41923. private _storedAlpha;
  41924. private _storedBeta;
  41925. private _storedRadius;
  41926. private _storedTarget;
  41927. private _storedTargetScreenOffset;
  41928. /**
  41929. * Stores the current state of the camera (alpha, beta, radius and target)
  41930. * @returns the camera itself
  41931. */
  41932. storeState(): Camera;
  41933. /**
  41934. * @hidden
  41935. * Restored camera state. You must call storeState() first
  41936. */
  41937. _restoreStateValues(): boolean;
  41938. /** @hidden */
  41939. _isSynchronizedViewMatrix(): boolean;
  41940. /**
  41941. * Attached controls to the current camera.
  41942. * @param element Defines the element the controls should be listened from
  41943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41944. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  41945. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  41946. */
  41947. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  41948. /**
  41949. * Detach the current controls from the camera.
  41950. * The camera will stop reacting to inputs.
  41951. * @param element Defines the element to stop listening the inputs from
  41952. */
  41953. detachControl(element: HTMLElement): void;
  41954. /** @hidden */
  41955. _checkInputs(): void;
  41956. protected _checkLimits(): void;
  41957. /**
  41958. * Rebuilds angles (alpha, beta) and radius from the give position and target
  41959. */
  41960. rebuildAnglesAndRadius(): void;
  41961. /**
  41962. * Use a position to define the current camera related information like alpha, beta and radius
  41963. * @param position Defines the position to set the camera at
  41964. */
  41965. setPosition(position: Vector3): void;
  41966. /**
  41967. * Defines the target the camera should look at.
  41968. * This will automatically adapt alpha beta and radius to fit within the new target.
  41969. * @param target Defines the new target as a Vector or a mesh
  41970. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  41971. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  41972. */
  41973. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  41974. /** @hidden */
  41975. _getViewMatrix(): Matrix;
  41976. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  41977. /**
  41978. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  41979. * @param meshes Defines the mesh to zoom on
  41980. * @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)
  41981. */
  41982. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  41983. /**
  41984. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  41985. * The target will be changed but the radius
  41986. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  41987. * @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)
  41988. */
  41989. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  41990. min: Vector3;
  41991. max: Vector3;
  41992. distance: number;
  41993. }, doNotUpdateMaxZ?: boolean): void;
  41994. /**
  41995. * @override
  41996. * Override Camera.createRigCamera
  41997. */
  41998. createRigCamera(name: string, cameraIndex: number): Camera;
  41999. /**
  42000. * @hidden
  42001. * @override
  42002. * Override Camera._updateRigCameras
  42003. */
  42004. _updateRigCameras(): void;
  42005. /**
  42006. * Destroy the camera and release the current resources hold by it.
  42007. */
  42008. dispose(): void;
  42009. /**
  42010. * Gets the current object class name.
  42011. * @return the class name
  42012. */
  42013. getClassName(): string;
  42014. }
  42015. }
  42016. declare module BABYLON {
  42017. /**
  42018. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42019. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42020. */
  42021. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42022. /**
  42023. * Gets the name of the behavior.
  42024. */
  42025. get name(): string;
  42026. private _zoomStopsAnimation;
  42027. private _idleRotationSpeed;
  42028. private _idleRotationWaitTime;
  42029. private _idleRotationSpinupTime;
  42030. /**
  42031. * Sets the flag that indicates if user zooming should stop animation.
  42032. */
  42033. set zoomStopsAnimation(flag: boolean);
  42034. /**
  42035. * Gets the flag that indicates if user zooming should stop animation.
  42036. */
  42037. get zoomStopsAnimation(): boolean;
  42038. /**
  42039. * Sets the default speed at which the camera rotates around the model.
  42040. */
  42041. set idleRotationSpeed(speed: number);
  42042. /**
  42043. * Gets the default speed at which the camera rotates around the model.
  42044. */
  42045. get idleRotationSpeed(): number;
  42046. /**
  42047. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42048. */
  42049. set idleRotationWaitTime(time: number);
  42050. /**
  42051. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42052. */
  42053. get idleRotationWaitTime(): number;
  42054. /**
  42055. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42056. */
  42057. set idleRotationSpinupTime(time: number);
  42058. /**
  42059. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42060. */
  42061. get idleRotationSpinupTime(): number;
  42062. /**
  42063. * Gets a value indicating if the camera is currently rotating because of this behavior
  42064. */
  42065. get rotationInProgress(): boolean;
  42066. private _onPrePointerObservableObserver;
  42067. private _onAfterCheckInputsObserver;
  42068. private _attachedCamera;
  42069. private _isPointerDown;
  42070. private _lastFrameTime;
  42071. private _lastInteractionTime;
  42072. private _cameraRotationSpeed;
  42073. /**
  42074. * Initializes the behavior.
  42075. */
  42076. init(): void;
  42077. /**
  42078. * Attaches the behavior to its arc rotate camera.
  42079. * @param camera Defines the camera to attach the behavior to
  42080. */
  42081. attach(camera: ArcRotateCamera): void;
  42082. /**
  42083. * Detaches the behavior from its current arc rotate camera.
  42084. */
  42085. detach(): void;
  42086. /**
  42087. * Returns true if user is scrolling.
  42088. * @return true if user is scrolling.
  42089. */
  42090. private _userIsZooming;
  42091. private _lastFrameRadius;
  42092. private _shouldAnimationStopForInteraction;
  42093. /**
  42094. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42095. */
  42096. private _applyUserInteraction;
  42097. private _userIsMoving;
  42098. }
  42099. }
  42100. declare module BABYLON {
  42101. /**
  42102. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42103. */
  42104. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42105. private ui;
  42106. /**
  42107. * The name of the behavior
  42108. */
  42109. name: string;
  42110. /**
  42111. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42112. */
  42113. distanceAwayFromFace: number;
  42114. /**
  42115. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42116. */
  42117. distanceAwayFromBottomOfFace: number;
  42118. private _faceVectors;
  42119. private _target;
  42120. private _scene;
  42121. private _onRenderObserver;
  42122. private _tmpMatrix;
  42123. private _tmpVector;
  42124. /**
  42125. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42126. * @param ui The transform node that should be attched to the mesh
  42127. */
  42128. constructor(ui: TransformNode);
  42129. /**
  42130. * Initializes the behavior
  42131. */
  42132. init(): void;
  42133. private _closestFace;
  42134. private _zeroVector;
  42135. private _lookAtTmpMatrix;
  42136. private _lookAtToRef;
  42137. /**
  42138. * Attaches the AttachToBoxBehavior to the passed in mesh
  42139. * @param target The mesh that the specified node will be attached to
  42140. */
  42141. attach(target: Mesh): void;
  42142. /**
  42143. * Detaches the behavior from the mesh
  42144. */
  42145. detach(): void;
  42146. }
  42147. }
  42148. declare module BABYLON {
  42149. /**
  42150. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42151. */
  42152. export class FadeInOutBehavior implements Behavior<Mesh> {
  42153. /**
  42154. * Time in milliseconds to delay before fading in (Default: 0)
  42155. */
  42156. delay: number;
  42157. /**
  42158. * Time in milliseconds for the mesh to fade in (Default: 300)
  42159. */
  42160. fadeInTime: number;
  42161. private _millisecondsPerFrame;
  42162. private _hovered;
  42163. private _hoverValue;
  42164. private _ownerNode;
  42165. /**
  42166. * Instatiates the FadeInOutBehavior
  42167. */
  42168. constructor();
  42169. /**
  42170. * The name of the behavior
  42171. */
  42172. get name(): string;
  42173. /**
  42174. * Initializes the behavior
  42175. */
  42176. init(): void;
  42177. /**
  42178. * Attaches the fade behavior on the passed in mesh
  42179. * @param ownerNode The mesh that will be faded in/out once attached
  42180. */
  42181. attach(ownerNode: Mesh): void;
  42182. /**
  42183. * Detaches the behavior from the mesh
  42184. */
  42185. detach(): void;
  42186. /**
  42187. * Triggers the mesh to begin fading in or out
  42188. * @param value if the object should fade in or out (true to fade in)
  42189. */
  42190. fadeIn(value: boolean): void;
  42191. private _update;
  42192. private _setAllVisibility;
  42193. }
  42194. }
  42195. declare module BABYLON {
  42196. /**
  42197. * Class containing a set of static utilities functions for managing Pivots
  42198. * @hidden
  42199. */
  42200. export class PivotTools {
  42201. private static _PivotCached;
  42202. private static _OldPivotPoint;
  42203. private static _PivotTranslation;
  42204. private static _PivotTmpVector;
  42205. /** @hidden */
  42206. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42207. /** @hidden */
  42208. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42209. }
  42210. }
  42211. declare module BABYLON {
  42212. /**
  42213. * Class containing static functions to help procedurally build meshes
  42214. */
  42215. export class PlaneBuilder {
  42216. /**
  42217. * Creates a plane mesh
  42218. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42219. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42220. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42222. * * 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
  42223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42224. * @param name defines the name of the mesh
  42225. * @param options defines the options used to create the mesh
  42226. * @param scene defines the hosting scene
  42227. * @returns the plane mesh
  42228. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42229. */
  42230. static CreatePlane(name: string, options: {
  42231. size?: number;
  42232. width?: number;
  42233. height?: number;
  42234. sideOrientation?: number;
  42235. frontUVs?: Vector4;
  42236. backUVs?: Vector4;
  42237. updatable?: boolean;
  42238. sourcePlane?: Plane;
  42239. }, scene?: Nullable<Scene>): Mesh;
  42240. }
  42241. }
  42242. declare module BABYLON {
  42243. /**
  42244. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42245. */
  42246. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42247. private static _AnyMouseID;
  42248. /**
  42249. * Abstract mesh the behavior is set on
  42250. */
  42251. attachedNode: AbstractMesh;
  42252. private _dragPlane;
  42253. private _scene;
  42254. private _pointerObserver;
  42255. private _beforeRenderObserver;
  42256. private static _planeScene;
  42257. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42258. /**
  42259. * 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)
  42260. */
  42261. maxDragAngle: number;
  42262. /**
  42263. * @hidden
  42264. */
  42265. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42266. /**
  42267. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42268. */
  42269. currentDraggingPointerID: number;
  42270. /**
  42271. * The last position where the pointer hit the drag plane in world space
  42272. */
  42273. lastDragPosition: Vector3;
  42274. /**
  42275. * If the behavior is currently in a dragging state
  42276. */
  42277. dragging: boolean;
  42278. /**
  42279. * 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)
  42280. */
  42281. dragDeltaRatio: number;
  42282. /**
  42283. * If the drag plane orientation should be updated during the dragging (Default: true)
  42284. */
  42285. updateDragPlane: boolean;
  42286. private _debugMode;
  42287. private _moving;
  42288. /**
  42289. * Fires each time the attached mesh is dragged with the pointer
  42290. * * delta between last drag position and current drag position in world space
  42291. * * dragDistance along the drag axis
  42292. * * dragPlaneNormal normal of the current drag plane used during the drag
  42293. * * dragPlanePoint in world space where the drag intersects the drag plane
  42294. */
  42295. onDragObservable: Observable<{
  42296. delta: Vector3;
  42297. dragPlanePoint: Vector3;
  42298. dragPlaneNormal: Vector3;
  42299. dragDistance: number;
  42300. pointerId: number;
  42301. }>;
  42302. /**
  42303. * Fires each time a drag begins (eg. mouse down on mesh)
  42304. */
  42305. onDragStartObservable: Observable<{
  42306. dragPlanePoint: Vector3;
  42307. pointerId: number;
  42308. }>;
  42309. /**
  42310. * Fires each time a drag ends (eg. mouse release after drag)
  42311. */
  42312. onDragEndObservable: Observable<{
  42313. dragPlanePoint: Vector3;
  42314. pointerId: number;
  42315. }>;
  42316. /**
  42317. * If the attached mesh should be moved when dragged
  42318. */
  42319. moveAttached: boolean;
  42320. /**
  42321. * If the drag behavior will react to drag events (Default: true)
  42322. */
  42323. enabled: boolean;
  42324. /**
  42325. * If pointer events should start and release the drag (Default: true)
  42326. */
  42327. startAndReleaseDragOnPointerEvents: boolean;
  42328. /**
  42329. * If camera controls should be detached during the drag
  42330. */
  42331. detachCameraControls: boolean;
  42332. /**
  42333. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42334. */
  42335. useObjectOrientationForDragging: boolean;
  42336. private _options;
  42337. /**
  42338. * Gets the options used by the behavior
  42339. */
  42340. get options(): {
  42341. dragAxis?: Vector3;
  42342. dragPlaneNormal?: Vector3;
  42343. };
  42344. /**
  42345. * Sets the options used by the behavior
  42346. */
  42347. set options(options: {
  42348. dragAxis?: Vector3;
  42349. dragPlaneNormal?: Vector3;
  42350. });
  42351. /**
  42352. * Creates a pointer drag behavior that can be attached to a mesh
  42353. * @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)
  42354. */
  42355. constructor(options?: {
  42356. dragAxis?: Vector3;
  42357. dragPlaneNormal?: Vector3;
  42358. });
  42359. /**
  42360. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42361. */
  42362. validateDrag: (targetPosition: Vector3) => boolean;
  42363. /**
  42364. * The name of the behavior
  42365. */
  42366. get name(): string;
  42367. /**
  42368. * Initializes the behavior
  42369. */
  42370. init(): void;
  42371. private _tmpVector;
  42372. private _alternatePickedPoint;
  42373. private _worldDragAxis;
  42374. private _targetPosition;
  42375. private _attachedElement;
  42376. /**
  42377. * Attaches the drag behavior the passed in mesh
  42378. * @param ownerNode The mesh that will be dragged around once attached
  42379. * @param predicate Predicate to use for pick filtering
  42380. */
  42381. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42382. /**
  42383. * Force relase the drag action by code.
  42384. */
  42385. releaseDrag(): void;
  42386. private _startDragRay;
  42387. private _lastPointerRay;
  42388. /**
  42389. * Simulates the start of a pointer drag event on the behavior
  42390. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42391. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42392. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42393. */
  42394. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42395. private _startDrag;
  42396. private _dragDelta;
  42397. private _moveDrag;
  42398. private _pickWithRayOnDragPlane;
  42399. private _pointA;
  42400. private _pointB;
  42401. private _pointC;
  42402. private _lineA;
  42403. private _lineB;
  42404. private _localAxis;
  42405. private _lookAt;
  42406. private _updateDragPlanePosition;
  42407. /**
  42408. * Detaches the behavior from the mesh
  42409. */
  42410. detach(): void;
  42411. }
  42412. }
  42413. declare module BABYLON {
  42414. /**
  42415. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42416. */
  42417. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42418. private _dragBehaviorA;
  42419. private _dragBehaviorB;
  42420. private _startDistance;
  42421. private _initialScale;
  42422. private _targetScale;
  42423. private _ownerNode;
  42424. private _sceneRenderObserver;
  42425. /**
  42426. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42427. */
  42428. constructor();
  42429. /**
  42430. * The name of the behavior
  42431. */
  42432. get name(): string;
  42433. /**
  42434. * Initializes the behavior
  42435. */
  42436. init(): void;
  42437. private _getCurrentDistance;
  42438. /**
  42439. * Attaches the scale behavior the passed in mesh
  42440. * @param ownerNode The mesh that will be scaled around once attached
  42441. */
  42442. attach(ownerNode: Mesh): void;
  42443. /**
  42444. * Detaches the behavior from the mesh
  42445. */
  42446. detach(): void;
  42447. }
  42448. }
  42449. declare module BABYLON {
  42450. /**
  42451. * 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
  42452. */
  42453. export class SixDofDragBehavior implements Behavior<Mesh> {
  42454. private static _virtualScene;
  42455. private _ownerNode;
  42456. private _sceneRenderObserver;
  42457. private _scene;
  42458. private _targetPosition;
  42459. private _virtualOriginMesh;
  42460. private _virtualDragMesh;
  42461. private _pointerObserver;
  42462. private _moving;
  42463. private _startingOrientation;
  42464. private _attachedElement;
  42465. /**
  42466. * 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)
  42467. */
  42468. private zDragFactor;
  42469. /**
  42470. * If the object should rotate to face the drag origin
  42471. */
  42472. rotateDraggedObject: boolean;
  42473. /**
  42474. * If the behavior is currently in a dragging state
  42475. */
  42476. dragging: boolean;
  42477. /**
  42478. * 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)
  42479. */
  42480. dragDeltaRatio: number;
  42481. /**
  42482. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42483. */
  42484. currentDraggingPointerID: number;
  42485. /**
  42486. * If camera controls should be detached during the drag
  42487. */
  42488. detachCameraControls: boolean;
  42489. /**
  42490. * Fires each time a drag starts
  42491. */
  42492. onDragStartObservable: Observable<{}>;
  42493. /**
  42494. * Fires each time a drag ends (eg. mouse release after drag)
  42495. */
  42496. onDragEndObservable: Observable<{}>;
  42497. /**
  42498. * 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
  42499. */
  42500. constructor();
  42501. /**
  42502. * The name of the behavior
  42503. */
  42504. get name(): string;
  42505. /**
  42506. * Initializes the behavior
  42507. */
  42508. init(): void;
  42509. /**
  42510. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42511. */
  42512. private get _pointerCamera();
  42513. /**
  42514. * Attaches the scale behavior the passed in mesh
  42515. * @param ownerNode The mesh that will be scaled around once attached
  42516. */
  42517. attach(ownerNode: Mesh): void;
  42518. /**
  42519. * Detaches the behavior from the mesh
  42520. */
  42521. detach(): void;
  42522. }
  42523. }
  42524. declare module BABYLON {
  42525. /**
  42526. * Class used to apply inverse kinematics to bones
  42527. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42528. */
  42529. export class BoneIKController {
  42530. private static _tmpVecs;
  42531. private static _tmpQuat;
  42532. private static _tmpMats;
  42533. /**
  42534. * Gets or sets the target mesh
  42535. */
  42536. targetMesh: AbstractMesh;
  42537. /** Gets or sets the mesh used as pole */
  42538. poleTargetMesh: AbstractMesh;
  42539. /**
  42540. * Gets or sets the bone used as pole
  42541. */
  42542. poleTargetBone: Nullable<Bone>;
  42543. /**
  42544. * Gets or sets the target position
  42545. */
  42546. targetPosition: Vector3;
  42547. /**
  42548. * Gets or sets the pole target position
  42549. */
  42550. poleTargetPosition: Vector3;
  42551. /**
  42552. * Gets or sets the pole target local offset
  42553. */
  42554. poleTargetLocalOffset: Vector3;
  42555. /**
  42556. * Gets or sets the pole angle
  42557. */
  42558. poleAngle: number;
  42559. /**
  42560. * Gets or sets the mesh associated with the controller
  42561. */
  42562. mesh: AbstractMesh;
  42563. /**
  42564. * 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)
  42565. */
  42566. slerpAmount: number;
  42567. private _bone1Quat;
  42568. private _bone1Mat;
  42569. private _bone2Ang;
  42570. private _bone1;
  42571. private _bone2;
  42572. private _bone1Length;
  42573. private _bone2Length;
  42574. private _maxAngle;
  42575. private _maxReach;
  42576. private _rightHandedSystem;
  42577. private _bendAxis;
  42578. private _slerping;
  42579. private _adjustRoll;
  42580. /**
  42581. * Gets or sets maximum allowed angle
  42582. */
  42583. get maxAngle(): number;
  42584. set maxAngle(value: number);
  42585. /**
  42586. * Creates a new BoneIKController
  42587. * @param mesh defines the mesh to control
  42588. * @param bone defines the bone to control
  42589. * @param options defines options to set up the controller
  42590. */
  42591. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42592. targetMesh?: AbstractMesh;
  42593. poleTargetMesh?: AbstractMesh;
  42594. poleTargetBone?: Bone;
  42595. poleTargetLocalOffset?: Vector3;
  42596. poleAngle?: number;
  42597. bendAxis?: Vector3;
  42598. maxAngle?: number;
  42599. slerpAmount?: number;
  42600. });
  42601. private _setMaxAngle;
  42602. /**
  42603. * Force the controller to update the bones
  42604. */
  42605. update(): void;
  42606. }
  42607. }
  42608. declare module BABYLON {
  42609. /**
  42610. * Class used to make a bone look toward a point in space
  42611. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42612. */
  42613. export class BoneLookController {
  42614. private static _tmpVecs;
  42615. private static _tmpQuat;
  42616. private static _tmpMats;
  42617. /**
  42618. * The target Vector3 that the bone will look at
  42619. */
  42620. target: Vector3;
  42621. /**
  42622. * The mesh that the bone is attached to
  42623. */
  42624. mesh: AbstractMesh;
  42625. /**
  42626. * The bone that will be looking to the target
  42627. */
  42628. bone: Bone;
  42629. /**
  42630. * The up axis of the coordinate system that is used when the bone is rotated
  42631. */
  42632. upAxis: Vector3;
  42633. /**
  42634. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42635. */
  42636. upAxisSpace: Space;
  42637. /**
  42638. * Used to make an adjustment to the yaw of the bone
  42639. */
  42640. adjustYaw: number;
  42641. /**
  42642. * Used to make an adjustment to the pitch of the bone
  42643. */
  42644. adjustPitch: number;
  42645. /**
  42646. * Used to make an adjustment to the roll of the bone
  42647. */
  42648. adjustRoll: number;
  42649. /**
  42650. * 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)
  42651. */
  42652. slerpAmount: number;
  42653. private _minYaw;
  42654. private _maxYaw;
  42655. private _minPitch;
  42656. private _maxPitch;
  42657. private _minYawSin;
  42658. private _minYawCos;
  42659. private _maxYawSin;
  42660. private _maxYawCos;
  42661. private _midYawConstraint;
  42662. private _minPitchTan;
  42663. private _maxPitchTan;
  42664. private _boneQuat;
  42665. private _slerping;
  42666. private _transformYawPitch;
  42667. private _transformYawPitchInv;
  42668. private _firstFrameSkipped;
  42669. private _yawRange;
  42670. private _fowardAxis;
  42671. /**
  42672. * Gets or sets the minimum yaw angle that the bone can look to
  42673. */
  42674. get minYaw(): number;
  42675. set minYaw(value: number);
  42676. /**
  42677. * Gets or sets the maximum yaw angle that the bone can look to
  42678. */
  42679. get maxYaw(): number;
  42680. set maxYaw(value: number);
  42681. /**
  42682. * Gets or sets the minimum pitch angle that the bone can look to
  42683. */
  42684. get minPitch(): number;
  42685. set minPitch(value: number);
  42686. /**
  42687. * Gets or sets the maximum pitch angle that the bone can look to
  42688. */
  42689. get maxPitch(): number;
  42690. set maxPitch(value: number);
  42691. /**
  42692. * Create a BoneLookController
  42693. * @param mesh the mesh that the bone belongs to
  42694. * @param bone the bone that will be looking to the target
  42695. * @param target the target Vector3 to look at
  42696. * @param options optional settings:
  42697. * * maxYaw: the maximum angle the bone will yaw to
  42698. * * minYaw: the minimum angle the bone will yaw to
  42699. * * maxPitch: the maximum angle the bone will pitch to
  42700. * * minPitch: the minimum angle the bone will yaw to
  42701. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42702. * * upAxis: the up axis of the coordinate system
  42703. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42704. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42705. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42706. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42707. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42708. * * adjustRoll: used to make an adjustment to the roll of the bone
  42709. **/
  42710. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42711. maxYaw?: number;
  42712. minYaw?: number;
  42713. maxPitch?: number;
  42714. minPitch?: number;
  42715. slerpAmount?: number;
  42716. upAxis?: Vector3;
  42717. upAxisSpace?: Space;
  42718. yawAxis?: Vector3;
  42719. pitchAxis?: Vector3;
  42720. adjustYaw?: number;
  42721. adjustPitch?: number;
  42722. adjustRoll?: number;
  42723. });
  42724. /**
  42725. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42726. */
  42727. update(): void;
  42728. private _getAngleDiff;
  42729. private _getAngleBetween;
  42730. private _isAngleBetween;
  42731. }
  42732. }
  42733. declare module BABYLON {
  42734. /**
  42735. * Manage the gamepad inputs to control an arc rotate camera.
  42736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42737. */
  42738. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42739. /**
  42740. * Defines the camera the input is attached to.
  42741. */
  42742. camera: ArcRotateCamera;
  42743. /**
  42744. * Defines the gamepad the input is gathering event from.
  42745. */
  42746. gamepad: Nullable<Gamepad>;
  42747. /**
  42748. * Defines the gamepad rotation sensiblity.
  42749. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42750. */
  42751. gamepadRotationSensibility: number;
  42752. /**
  42753. * Defines the gamepad move sensiblity.
  42754. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42755. */
  42756. gamepadMoveSensibility: number;
  42757. private _yAxisScale;
  42758. /**
  42759. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42760. */
  42761. get invertYAxis(): boolean;
  42762. set invertYAxis(value: boolean);
  42763. private _onGamepadConnectedObserver;
  42764. private _onGamepadDisconnectedObserver;
  42765. /**
  42766. * Attach the input controls to a specific dom element to get the input from.
  42767. * @param element Defines the element the controls should be listened from
  42768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42769. */
  42770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42771. /**
  42772. * Detach the current controls from the specified dom element.
  42773. * @param element Defines the element to stop listening the inputs from
  42774. */
  42775. detachControl(element: Nullable<HTMLElement>): void;
  42776. /**
  42777. * Update the current camera state depending on the inputs that have been used this frame.
  42778. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42779. */
  42780. checkInputs(): void;
  42781. /**
  42782. * Gets the class name of the current intput.
  42783. * @returns the class name
  42784. */
  42785. getClassName(): string;
  42786. /**
  42787. * Get the friendly name associated with the input class.
  42788. * @returns the input friendly name
  42789. */
  42790. getSimpleName(): string;
  42791. }
  42792. }
  42793. declare module BABYLON {
  42794. interface ArcRotateCameraInputsManager {
  42795. /**
  42796. * Add orientation input support to the input manager.
  42797. * @returns the current input manager
  42798. */
  42799. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  42800. }
  42801. /**
  42802. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  42803. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42804. */
  42805. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  42806. /**
  42807. * Defines the camera the input is attached to.
  42808. */
  42809. camera: ArcRotateCamera;
  42810. /**
  42811. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  42812. */
  42813. alphaCorrection: number;
  42814. /**
  42815. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  42816. */
  42817. gammaCorrection: number;
  42818. private _alpha;
  42819. private _gamma;
  42820. private _dirty;
  42821. private _deviceOrientationHandler;
  42822. /**
  42823. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  42824. */
  42825. constructor();
  42826. /**
  42827. * Attach the input controls to a specific dom element to get the input from.
  42828. * @param element Defines the element the controls should be listened from
  42829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42830. */
  42831. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42832. /** @hidden */
  42833. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  42834. /**
  42835. * Update the current camera state depending on the inputs that have been used this frame.
  42836. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42837. */
  42838. checkInputs(): void;
  42839. /**
  42840. * Detach the current controls from the specified dom element.
  42841. * @param element Defines the element to stop listening the inputs from
  42842. */
  42843. detachControl(element: Nullable<HTMLElement>): void;
  42844. /**
  42845. * Gets the class name of the current intput.
  42846. * @returns the class name
  42847. */
  42848. getClassName(): string;
  42849. /**
  42850. * Get the friendly name associated with the input class.
  42851. * @returns the input friendly name
  42852. */
  42853. getSimpleName(): string;
  42854. }
  42855. }
  42856. declare module BABYLON {
  42857. /**
  42858. * Listen to mouse events to control the camera.
  42859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42860. */
  42861. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  42862. /**
  42863. * Defines the camera the input is attached to.
  42864. */
  42865. camera: FlyCamera;
  42866. /**
  42867. * Defines if touch is enabled. (Default is true.)
  42868. */
  42869. touchEnabled: boolean;
  42870. /**
  42871. * Defines the buttons associated with the input to handle camera rotation.
  42872. */
  42873. buttons: number[];
  42874. /**
  42875. * Assign buttons for Yaw control.
  42876. */
  42877. buttonsYaw: number[];
  42878. /**
  42879. * Assign buttons for Pitch control.
  42880. */
  42881. buttonsPitch: number[];
  42882. /**
  42883. * Assign buttons for Roll control.
  42884. */
  42885. buttonsRoll: number[];
  42886. /**
  42887. * Detect if any button is being pressed while mouse is moved.
  42888. * -1 = Mouse locked.
  42889. * 0 = Left button.
  42890. * 1 = Middle Button.
  42891. * 2 = Right Button.
  42892. */
  42893. activeButton: number;
  42894. /**
  42895. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  42896. * Higher values reduce its sensitivity.
  42897. */
  42898. angularSensibility: number;
  42899. private _mousemoveCallback;
  42900. private _observer;
  42901. private _rollObserver;
  42902. private previousPosition;
  42903. private noPreventDefault;
  42904. private element;
  42905. /**
  42906. * Listen to mouse events to control the camera.
  42907. * @param touchEnabled Define if touch is enabled. (Default is true.)
  42908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42909. */
  42910. constructor(touchEnabled?: boolean);
  42911. /**
  42912. * Attach the mouse control to the HTML DOM element.
  42913. * @param element Defines the element that listens to the input events.
  42914. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  42915. */
  42916. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42917. /**
  42918. * Detach the current controls from the specified dom element.
  42919. * @param element Defines the element to stop listening the inputs from
  42920. */
  42921. detachControl(element: Nullable<HTMLElement>): void;
  42922. /**
  42923. * Gets the class name of the current input.
  42924. * @returns the class name.
  42925. */
  42926. getClassName(): string;
  42927. /**
  42928. * Get the friendly name associated with the input class.
  42929. * @returns the input's friendly name.
  42930. */
  42931. getSimpleName(): string;
  42932. private _pointerInput;
  42933. private _onMouseMove;
  42934. /**
  42935. * Rotate camera by mouse offset.
  42936. */
  42937. private rotateCamera;
  42938. }
  42939. }
  42940. declare module BABYLON {
  42941. /**
  42942. * Default Inputs manager for the FlyCamera.
  42943. * It groups all the default supported inputs for ease of use.
  42944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42945. */
  42946. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  42947. /**
  42948. * Instantiates a new FlyCameraInputsManager.
  42949. * @param camera Defines the camera the inputs belong to.
  42950. */
  42951. constructor(camera: FlyCamera);
  42952. /**
  42953. * Add keyboard input support to the input manager.
  42954. * @returns the new FlyCameraKeyboardMoveInput().
  42955. */
  42956. addKeyboard(): FlyCameraInputsManager;
  42957. /**
  42958. * Add mouse input support to the input manager.
  42959. * @param touchEnabled Enable touch screen support.
  42960. * @returns the new FlyCameraMouseInput().
  42961. */
  42962. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  42963. }
  42964. }
  42965. declare module BABYLON {
  42966. /**
  42967. * This is a flying camera, designed for 3D movement and rotation in all directions,
  42968. * such as in a 3D Space Shooter or a Flight Simulator.
  42969. */
  42970. export class FlyCamera extends TargetCamera {
  42971. /**
  42972. * Define the collision ellipsoid of the camera.
  42973. * This is helpful for simulating a camera body, like a player's body.
  42974. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42975. */
  42976. ellipsoid: Vector3;
  42977. /**
  42978. * Define an offset for the position of the ellipsoid around the camera.
  42979. * This can be helpful if the camera is attached away from the player's body center,
  42980. * such as at its head.
  42981. */
  42982. ellipsoidOffset: Vector3;
  42983. /**
  42984. * Enable or disable collisions of the camera with the rest of the scene objects.
  42985. */
  42986. checkCollisions: boolean;
  42987. /**
  42988. * Enable or disable gravity on the camera.
  42989. */
  42990. applyGravity: boolean;
  42991. /**
  42992. * Define the current direction the camera is moving to.
  42993. */
  42994. cameraDirection: Vector3;
  42995. /**
  42996. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  42997. * This overrides and empties cameraRotation.
  42998. */
  42999. rotationQuaternion: Quaternion;
  43000. /**
  43001. * Track Roll to maintain the wanted Rolling when looking around.
  43002. */
  43003. _trackRoll: number;
  43004. /**
  43005. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43006. */
  43007. rollCorrect: number;
  43008. /**
  43009. * Mimic a banked turn, Rolling the camera when Yawing.
  43010. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43011. */
  43012. bankedTurn: boolean;
  43013. /**
  43014. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43015. */
  43016. bankedTurnLimit: number;
  43017. /**
  43018. * Value of 0 disables the banked Roll.
  43019. * Value of 1 is equal to the Yaw angle in radians.
  43020. */
  43021. bankedTurnMultiplier: number;
  43022. /**
  43023. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43024. */
  43025. inputs: FlyCameraInputsManager;
  43026. /**
  43027. * Gets the input sensibility for mouse input.
  43028. * Higher values reduce sensitivity.
  43029. */
  43030. get angularSensibility(): number;
  43031. /**
  43032. * Sets the input sensibility for a mouse input.
  43033. * Higher values reduce sensitivity.
  43034. */
  43035. set angularSensibility(value: number);
  43036. /**
  43037. * Get the keys for camera movement forward.
  43038. */
  43039. get keysForward(): number[];
  43040. /**
  43041. * Set the keys for camera movement forward.
  43042. */
  43043. set keysForward(value: number[]);
  43044. /**
  43045. * Get the keys for camera movement backward.
  43046. */
  43047. get keysBackward(): number[];
  43048. set keysBackward(value: number[]);
  43049. /**
  43050. * Get the keys for camera movement up.
  43051. */
  43052. get keysUp(): number[];
  43053. /**
  43054. * Set the keys for camera movement up.
  43055. */
  43056. set keysUp(value: number[]);
  43057. /**
  43058. * Get the keys for camera movement down.
  43059. */
  43060. get keysDown(): number[];
  43061. /**
  43062. * Set the keys for camera movement down.
  43063. */
  43064. set keysDown(value: number[]);
  43065. /**
  43066. * Get the keys for camera movement left.
  43067. */
  43068. get keysLeft(): number[];
  43069. /**
  43070. * Set the keys for camera movement left.
  43071. */
  43072. set keysLeft(value: number[]);
  43073. /**
  43074. * Set the keys for camera movement right.
  43075. */
  43076. get keysRight(): number[];
  43077. /**
  43078. * Set the keys for camera movement right.
  43079. */
  43080. set keysRight(value: number[]);
  43081. /**
  43082. * Event raised when the camera collides with a mesh in the scene.
  43083. */
  43084. onCollide: (collidedMesh: AbstractMesh) => void;
  43085. private _collider;
  43086. private _needMoveForGravity;
  43087. private _oldPosition;
  43088. private _diffPosition;
  43089. private _newPosition;
  43090. /** @hidden */
  43091. _localDirection: Vector3;
  43092. /** @hidden */
  43093. _transformedDirection: Vector3;
  43094. /**
  43095. * Instantiates a FlyCamera.
  43096. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43097. * such as in a 3D Space Shooter or a Flight Simulator.
  43098. * @param name Define the name of the camera in the scene.
  43099. * @param position Define the starting position of the camera in the scene.
  43100. * @param scene Define the scene the camera belongs to.
  43101. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43102. */
  43103. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43104. /**
  43105. * Attach a control to the HTML DOM element.
  43106. * @param element Defines the element that listens to the input events.
  43107. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43108. */
  43109. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43110. /**
  43111. * Detach a control from the HTML DOM element.
  43112. * The camera will stop reacting to that input.
  43113. * @param element Defines the element that listens to the input events.
  43114. */
  43115. detachControl(element: HTMLElement): void;
  43116. private _collisionMask;
  43117. /**
  43118. * Get the mask that the camera ignores in collision events.
  43119. */
  43120. get collisionMask(): number;
  43121. /**
  43122. * Set the mask that the camera ignores in collision events.
  43123. */
  43124. set collisionMask(mask: number);
  43125. /** @hidden */
  43126. _collideWithWorld(displacement: Vector3): void;
  43127. /** @hidden */
  43128. private _onCollisionPositionChange;
  43129. /** @hidden */
  43130. _checkInputs(): void;
  43131. /** @hidden */
  43132. _decideIfNeedsToMove(): boolean;
  43133. /** @hidden */
  43134. _updatePosition(): void;
  43135. /**
  43136. * Restore the Roll to its target value at the rate specified.
  43137. * @param rate - Higher means slower restoring.
  43138. * @hidden
  43139. */
  43140. restoreRoll(rate: number): void;
  43141. /**
  43142. * Destroy the camera and release the current resources held by it.
  43143. */
  43144. dispose(): void;
  43145. /**
  43146. * Get the current object class name.
  43147. * @returns the class name.
  43148. */
  43149. getClassName(): string;
  43150. }
  43151. }
  43152. declare module BABYLON {
  43153. /**
  43154. * Listen to keyboard events to control the camera.
  43155. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43156. */
  43157. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43158. /**
  43159. * Defines the camera the input is attached to.
  43160. */
  43161. camera: FlyCamera;
  43162. /**
  43163. * The list of keyboard keys used to control the forward move of the camera.
  43164. */
  43165. keysForward: number[];
  43166. /**
  43167. * The list of keyboard keys used to control the backward move of the camera.
  43168. */
  43169. keysBackward: number[];
  43170. /**
  43171. * The list of keyboard keys used to control the forward move of the camera.
  43172. */
  43173. keysUp: number[];
  43174. /**
  43175. * The list of keyboard keys used to control the backward move of the camera.
  43176. */
  43177. keysDown: number[];
  43178. /**
  43179. * The list of keyboard keys used to control the right strafe move of the camera.
  43180. */
  43181. keysRight: number[];
  43182. /**
  43183. * The list of keyboard keys used to control the left strafe move of the camera.
  43184. */
  43185. keysLeft: number[];
  43186. private _keys;
  43187. private _onCanvasBlurObserver;
  43188. private _onKeyboardObserver;
  43189. private _engine;
  43190. private _scene;
  43191. /**
  43192. * Attach the input controls to a specific dom element to get the input from.
  43193. * @param element Defines the element the controls should be listened from
  43194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43195. */
  43196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43197. /**
  43198. * Detach the current controls from the specified dom element.
  43199. * @param element Defines the element to stop listening the inputs from
  43200. */
  43201. detachControl(element: Nullable<HTMLElement>): void;
  43202. /**
  43203. * Gets the class name of the current intput.
  43204. * @returns the class name
  43205. */
  43206. getClassName(): string;
  43207. /** @hidden */
  43208. _onLostFocus(e: FocusEvent): void;
  43209. /**
  43210. * Get the friendly name associated with the input class.
  43211. * @returns the input friendly name
  43212. */
  43213. getSimpleName(): string;
  43214. /**
  43215. * Update the current camera state depending on the inputs that have been used this frame.
  43216. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43217. */
  43218. checkInputs(): void;
  43219. }
  43220. }
  43221. declare module BABYLON {
  43222. /**
  43223. * Manage the mouse wheel inputs to control a follow camera.
  43224. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43225. */
  43226. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43227. /**
  43228. * Defines the camera the input is attached to.
  43229. */
  43230. camera: FollowCamera;
  43231. /**
  43232. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43233. */
  43234. axisControlRadius: boolean;
  43235. /**
  43236. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43237. */
  43238. axisControlHeight: boolean;
  43239. /**
  43240. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43241. */
  43242. axisControlRotation: boolean;
  43243. /**
  43244. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43245. * relation to mouseWheel events.
  43246. */
  43247. wheelPrecision: number;
  43248. /**
  43249. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43250. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43251. */
  43252. wheelDeltaPercentage: number;
  43253. private _wheel;
  43254. private _observer;
  43255. /**
  43256. * Attach the input controls to a specific dom element to get the input from.
  43257. * @param element Defines the element the controls should be listened from
  43258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43259. */
  43260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43261. /**
  43262. * Detach the current controls from the specified dom element.
  43263. * @param element Defines the element to stop listening the inputs from
  43264. */
  43265. detachControl(element: Nullable<HTMLElement>): void;
  43266. /**
  43267. * Gets the class name of the current intput.
  43268. * @returns the class name
  43269. */
  43270. getClassName(): string;
  43271. /**
  43272. * Get the friendly name associated with the input class.
  43273. * @returns the input friendly name
  43274. */
  43275. getSimpleName(): string;
  43276. }
  43277. }
  43278. declare module BABYLON {
  43279. /**
  43280. * Manage the pointers inputs to control an follow camera.
  43281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43282. */
  43283. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43284. /**
  43285. * Defines the camera the input is attached to.
  43286. */
  43287. camera: FollowCamera;
  43288. /**
  43289. * Gets the class name of the current input.
  43290. * @returns the class name
  43291. */
  43292. getClassName(): string;
  43293. /**
  43294. * Defines the pointer angular sensibility along the X axis or how fast is
  43295. * the camera rotating.
  43296. * A negative number will reverse the axis direction.
  43297. */
  43298. angularSensibilityX: number;
  43299. /**
  43300. * Defines the pointer angular sensibility along the Y axis or how fast is
  43301. * the camera rotating.
  43302. * A negative number will reverse the axis direction.
  43303. */
  43304. angularSensibilityY: number;
  43305. /**
  43306. * Defines the pointer pinch precision or how fast is the camera zooming.
  43307. * A negative number will reverse the axis direction.
  43308. */
  43309. pinchPrecision: number;
  43310. /**
  43311. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43312. * from 0.
  43313. * It defines the percentage of current camera.radius to use as delta when
  43314. * pinch zoom is used.
  43315. */
  43316. pinchDeltaPercentage: number;
  43317. /**
  43318. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43319. */
  43320. axisXControlRadius: boolean;
  43321. /**
  43322. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43323. */
  43324. axisXControlHeight: boolean;
  43325. /**
  43326. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43327. */
  43328. axisXControlRotation: boolean;
  43329. /**
  43330. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43331. */
  43332. axisYControlRadius: boolean;
  43333. /**
  43334. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43335. */
  43336. axisYControlHeight: boolean;
  43337. /**
  43338. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43339. */
  43340. axisYControlRotation: boolean;
  43341. /**
  43342. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43343. */
  43344. axisPinchControlRadius: boolean;
  43345. /**
  43346. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43347. */
  43348. axisPinchControlHeight: boolean;
  43349. /**
  43350. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43351. */
  43352. axisPinchControlRotation: boolean;
  43353. /**
  43354. * Log error messages if basic misconfiguration has occurred.
  43355. */
  43356. warningEnable: boolean;
  43357. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43358. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43359. private _warningCounter;
  43360. private _warning;
  43361. }
  43362. }
  43363. declare module BABYLON {
  43364. /**
  43365. * Default Inputs manager for the FollowCamera.
  43366. * It groups all the default supported inputs for ease of use.
  43367. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43368. */
  43369. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43370. /**
  43371. * Instantiates a new FollowCameraInputsManager.
  43372. * @param camera Defines the camera the inputs belong to
  43373. */
  43374. constructor(camera: FollowCamera);
  43375. /**
  43376. * Add keyboard input support to the input manager.
  43377. * @returns the current input manager
  43378. */
  43379. addKeyboard(): FollowCameraInputsManager;
  43380. /**
  43381. * Add mouse wheel input support to the input manager.
  43382. * @returns the current input manager
  43383. */
  43384. addMouseWheel(): FollowCameraInputsManager;
  43385. /**
  43386. * Add pointers input support to the input manager.
  43387. * @returns the current input manager
  43388. */
  43389. addPointers(): FollowCameraInputsManager;
  43390. /**
  43391. * Add orientation input support to the input manager.
  43392. * @returns the current input manager
  43393. */
  43394. addVRDeviceOrientation(): FollowCameraInputsManager;
  43395. }
  43396. }
  43397. declare module BABYLON {
  43398. /**
  43399. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43400. * an arc rotate version arcFollowCamera are available.
  43401. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43402. */
  43403. export class FollowCamera extends TargetCamera {
  43404. /**
  43405. * Distance the follow camera should follow an object at
  43406. */
  43407. radius: number;
  43408. /**
  43409. * Minimum allowed distance of the camera to the axis of rotation
  43410. * (The camera can not get closer).
  43411. * This can help limiting how the Camera is able to move in the scene.
  43412. */
  43413. lowerRadiusLimit: Nullable<number>;
  43414. /**
  43415. * Maximum allowed distance of the camera to the axis of rotation
  43416. * (The camera can not get further).
  43417. * This can help limiting how the Camera is able to move in the scene.
  43418. */
  43419. upperRadiusLimit: Nullable<number>;
  43420. /**
  43421. * Define a rotation offset between the camera and the object it follows
  43422. */
  43423. rotationOffset: number;
  43424. /**
  43425. * Minimum allowed angle to camera position relative to target object.
  43426. * This can help limiting how the Camera is able to move in the scene.
  43427. */
  43428. lowerRotationOffsetLimit: Nullable<number>;
  43429. /**
  43430. * Maximum allowed angle to camera position relative to target object.
  43431. * This can help limiting how the Camera is able to move in the scene.
  43432. */
  43433. upperRotationOffsetLimit: Nullable<number>;
  43434. /**
  43435. * Define a height offset between the camera and the object it follows.
  43436. * It can help following an object from the top (like a car chaing a plane)
  43437. */
  43438. heightOffset: number;
  43439. /**
  43440. * Minimum allowed height of camera position relative to target object.
  43441. * This can help limiting how the Camera is able to move in the scene.
  43442. */
  43443. lowerHeightOffsetLimit: Nullable<number>;
  43444. /**
  43445. * Maximum allowed height of camera position relative to target object.
  43446. * This can help limiting how the Camera is able to move in the scene.
  43447. */
  43448. upperHeightOffsetLimit: Nullable<number>;
  43449. /**
  43450. * Define how fast the camera can accelerate to follow it s target.
  43451. */
  43452. cameraAcceleration: number;
  43453. /**
  43454. * Define the speed limit of the camera following an object.
  43455. */
  43456. maxCameraSpeed: number;
  43457. /**
  43458. * Define the target of the camera.
  43459. */
  43460. lockedTarget: Nullable<AbstractMesh>;
  43461. /**
  43462. * Defines the input associated with the camera.
  43463. */
  43464. inputs: FollowCameraInputsManager;
  43465. /**
  43466. * Instantiates the follow camera.
  43467. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43468. * @param name Define the name of the camera in the scene
  43469. * @param position Define the position of the camera
  43470. * @param scene Define the scene the camera belong to
  43471. * @param lockedTarget Define the target of the camera
  43472. */
  43473. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43474. private _follow;
  43475. /**
  43476. * Attached controls to the current camera.
  43477. * @param element Defines the element the controls should be listened from
  43478. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43479. */
  43480. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43481. /**
  43482. * Detach the current controls from the camera.
  43483. * The camera will stop reacting to inputs.
  43484. * @param element Defines the element to stop listening the inputs from
  43485. */
  43486. detachControl(element: HTMLElement): void;
  43487. /** @hidden */
  43488. _checkInputs(): void;
  43489. private _checkLimits;
  43490. /**
  43491. * Gets the camera class name.
  43492. * @returns the class name
  43493. */
  43494. getClassName(): string;
  43495. }
  43496. /**
  43497. * Arc Rotate version of the follow camera.
  43498. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43499. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43500. */
  43501. export class ArcFollowCamera extends TargetCamera {
  43502. /** The longitudinal angle of the camera */
  43503. alpha: number;
  43504. /** The latitudinal angle of the camera */
  43505. beta: number;
  43506. /** The radius of the camera from its target */
  43507. radius: number;
  43508. /** Define the camera target (the messh it should follow) */
  43509. target: Nullable<AbstractMesh>;
  43510. private _cartesianCoordinates;
  43511. /**
  43512. * Instantiates a new ArcFollowCamera
  43513. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43514. * @param name Define the name of the camera
  43515. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43516. * @param beta Define the rotation angle of the camera around the elevation axis
  43517. * @param radius Define the radius of the camera from its target point
  43518. * @param target Define the target of the camera
  43519. * @param scene Define the scene the camera belongs to
  43520. */
  43521. constructor(name: string,
  43522. /** The longitudinal angle of the camera */
  43523. alpha: number,
  43524. /** The latitudinal angle of the camera */
  43525. beta: number,
  43526. /** The radius of the camera from its target */
  43527. radius: number,
  43528. /** Define the camera target (the messh it should follow) */
  43529. target: Nullable<AbstractMesh>, scene: Scene);
  43530. private _follow;
  43531. /** @hidden */
  43532. _checkInputs(): void;
  43533. /**
  43534. * Returns the class name of the object.
  43535. * It is mostly used internally for serialization purposes.
  43536. */
  43537. getClassName(): string;
  43538. }
  43539. }
  43540. declare module BABYLON {
  43541. /**
  43542. * Manage the keyboard inputs to control the movement of a follow camera.
  43543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43544. */
  43545. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43546. /**
  43547. * Defines the camera the input is attached to.
  43548. */
  43549. camera: FollowCamera;
  43550. /**
  43551. * Defines the list of key codes associated with the up action (increase heightOffset)
  43552. */
  43553. keysHeightOffsetIncr: number[];
  43554. /**
  43555. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43556. */
  43557. keysHeightOffsetDecr: number[];
  43558. /**
  43559. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43560. */
  43561. keysHeightOffsetModifierAlt: boolean;
  43562. /**
  43563. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43564. */
  43565. keysHeightOffsetModifierCtrl: boolean;
  43566. /**
  43567. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43568. */
  43569. keysHeightOffsetModifierShift: boolean;
  43570. /**
  43571. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43572. */
  43573. keysRotationOffsetIncr: number[];
  43574. /**
  43575. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43576. */
  43577. keysRotationOffsetDecr: number[];
  43578. /**
  43579. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43580. */
  43581. keysRotationOffsetModifierAlt: boolean;
  43582. /**
  43583. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43584. */
  43585. keysRotationOffsetModifierCtrl: boolean;
  43586. /**
  43587. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43588. */
  43589. keysRotationOffsetModifierShift: boolean;
  43590. /**
  43591. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43592. */
  43593. keysRadiusIncr: number[];
  43594. /**
  43595. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43596. */
  43597. keysRadiusDecr: number[];
  43598. /**
  43599. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43600. */
  43601. keysRadiusModifierAlt: boolean;
  43602. /**
  43603. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43604. */
  43605. keysRadiusModifierCtrl: boolean;
  43606. /**
  43607. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43608. */
  43609. keysRadiusModifierShift: boolean;
  43610. /**
  43611. * Defines the rate of change of heightOffset.
  43612. */
  43613. heightSensibility: number;
  43614. /**
  43615. * Defines the rate of change of rotationOffset.
  43616. */
  43617. rotationSensibility: number;
  43618. /**
  43619. * Defines the rate of change of radius.
  43620. */
  43621. radiusSensibility: number;
  43622. private _keys;
  43623. private _ctrlPressed;
  43624. private _altPressed;
  43625. private _shiftPressed;
  43626. private _onCanvasBlurObserver;
  43627. private _onKeyboardObserver;
  43628. private _engine;
  43629. private _scene;
  43630. /**
  43631. * Attach the input controls to a specific dom element to get the input from.
  43632. * @param element Defines the element the controls should be listened from
  43633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43634. */
  43635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43636. /**
  43637. * Detach the current controls from the specified dom element.
  43638. * @param element Defines the element to stop listening the inputs from
  43639. */
  43640. detachControl(element: Nullable<HTMLElement>): void;
  43641. /**
  43642. * Update the current camera state depending on the inputs that have been used this frame.
  43643. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43644. */
  43645. checkInputs(): void;
  43646. /**
  43647. * Gets the class name of the current input.
  43648. * @returns the class name
  43649. */
  43650. getClassName(): string;
  43651. /**
  43652. * Get the friendly name associated with the input class.
  43653. * @returns the input friendly name
  43654. */
  43655. getSimpleName(): string;
  43656. /**
  43657. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43658. * allow modification of the heightOffset value.
  43659. */
  43660. private _modifierHeightOffset;
  43661. /**
  43662. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43663. * allow modification of the rotationOffset value.
  43664. */
  43665. private _modifierRotationOffset;
  43666. /**
  43667. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43668. * allow modification of the radius value.
  43669. */
  43670. private _modifierRadius;
  43671. }
  43672. }
  43673. declare module BABYLON {
  43674. interface FreeCameraInputsManager {
  43675. /**
  43676. * @hidden
  43677. */
  43678. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43679. /**
  43680. * Add orientation input support to the input manager.
  43681. * @returns the current input manager
  43682. */
  43683. addDeviceOrientation(): FreeCameraInputsManager;
  43684. }
  43685. /**
  43686. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43687. * Screen rotation is taken into account.
  43688. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43689. */
  43690. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43691. private _camera;
  43692. private _screenOrientationAngle;
  43693. private _constantTranform;
  43694. private _screenQuaternion;
  43695. private _alpha;
  43696. private _beta;
  43697. private _gamma;
  43698. /**
  43699. * Can be used to detect if a device orientation sensor is available on a device
  43700. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43701. * @returns a promise that will resolve on orientation change
  43702. */
  43703. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43704. /**
  43705. * @hidden
  43706. */
  43707. _onDeviceOrientationChangedObservable: Observable<void>;
  43708. /**
  43709. * Instantiates a new input
  43710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43711. */
  43712. constructor();
  43713. /**
  43714. * Define the camera controlled by the input.
  43715. */
  43716. get camera(): FreeCamera;
  43717. set camera(camera: FreeCamera);
  43718. /**
  43719. * Attach the input controls to a specific dom element to get the input from.
  43720. * @param element Defines the element the controls should be listened from
  43721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43722. */
  43723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43724. private _orientationChanged;
  43725. private _deviceOrientation;
  43726. /**
  43727. * Detach the current controls from the specified dom element.
  43728. * @param element Defines the element to stop listening the inputs from
  43729. */
  43730. detachControl(element: Nullable<HTMLElement>): void;
  43731. /**
  43732. * Update the current camera state depending on the inputs that have been used this frame.
  43733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43734. */
  43735. checkInputs(): void;
  43736. /**
  43737. * Gets the class name of the current intput.
  43738. * @returns the class name
  43739. */
  43740. getClassName(): string;
  43741. /**
  43742. * Get the friendly name associated with the input class.
  43743. * @returns the input friendly name
  43744. */
  43745. getSimpleName(): string;
  43746. }
  43747. }
  43748. declare module BABYLON {
  43749. /**
  43750. * Manage the gamepad inputs to control a free camera.
  43751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43752. */
  43753. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  43754. /**
  43755. * Define the camera the input is attached to.
  43756. */
  43757. camera: FreeCamera;
  43758. /**
  43759. * Define the Gamepad controlling the input
  43760. */
  43761. gamepad: Nullable<Gamepad>;
  43762. /**
  43763. * Defines the gamepad rotation sensiblity.
  43764. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43765. */
  43766. gamepadAngularSensibility: number;
  43767. /**
  43768. * Defines the gamepad move sensiblity.
  43769. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43770. */
  43771. gamepadMoveSensibility: number;
  43772. private _yAxisScale;
  43773. /**
  43774. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43775. */
  43776. get invertYAxis(): boolean;
  43777. set invertYAxis(value: boolean);
  43778. private _onGamepadConnectedObserver;
  43779. private _onGamepadDisconnectedObserver;
  43780. private _cameraTransform;
  43781. private _deltaTransform;
  43782. private _vector3;
  43783. private _vector2;
  43784. /**
  43785. * Attach the input controls to a specific dom element to get the input from.
  43786. * @param element Defines the element the controls should be listened from
  43787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43788. */
  43789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43790. /**
  43791. * Detach the current controls from the specified dom element.
  43792. * @param element Defines the element to stop listening the inputs from
  43793. */
  43794. detachControl(element: Nullable<HTMLElement>): void;
  43795. /**
  43796. * Update the current camera state depending on the inputs that have been used this frame.
  43797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43798. */
  43799. checkInputs(): void;
  43800. /**
  43801. * Gets the class name of the current intput.
  43802. * @returns the class name
  43803. */
  43804. getClassName(): string;
  43805. /**
  43806. * Get the friendly name associated with the input class.
  43807. * @returns the input friendly name
  43808. */
  43809. getSimpleName(): string;
  43810. }
  43811. }
  43812. declare module BABYLON {
  43813. /**
  43814. * Defines the potential axis of a Joystick
  43815. */
  43816. export enum JoystickAxis {
  43817. /** X axis */
  43818. X = 0,
  43819. /** Y axis */
  43820. Y = 1,
  43821. /** Z axis */
  43822. Z = 2
  43823. }
  43824. /**
  43825. * Class used to define virtual joystick (used in touch mode)
  43826. */
  43827. export class VirtualJoystick {
  43828. /**
  43829. * Gets or sets a boolean indicating that left and right values must be inverted
  43830. */
  43831. reverseLeftRight: boolean;
  43832. /**
  43833. * Gets or sets a boolean indicating that up and down values must be inverted
  43834. */
  43835. reverseUpDown: boolean;
  43836. /**
  43837. * Gets the offset value for the position (ie. the change of the position value)
  43838. */
  43839. deltaPosition: Vector3;
  43840. /**
  43841. * Gets a boolean indicating if the virtual joystick was pressed
  43842. */
  43843. pressed: boolean;
  43844. /**
  43845. * Canvas the virtual joystick will render onto, default z-index of this is 5
  43846. */
  43847. static Canvas: Nullable<HTMLCanvasElement>;
  43848. private static _globalJoystickIndex;
  43849. private static vjCanvasContext;
  43850. private static vjCanvasWidth;
  43851. private static vjCanvasHeight;
  43852. private static halfWidth;
  43853. private _action;
  43854. private _axisTargetedByLeftAndRight;
  43855. private _axisTargetedByUpAndDown;
  43856. private _joystickSensibility;
  43857. private _inversedSensibility;
  43858. private _joystickPointerID;
  43859. private _joystickColor;
  43860. private _joystickPointerPos;
  43861. private _joystickPreviousPointerPos;
  43862. private _joystickPointerStartPos;
  43863. private _deltaJoystickVector;
  43864. private _leftJoystick;
  43865. private _touches;
  43866. private _onPointerDownHandlerRef;
  43867. private _onPointerMoveHandlerRef;
  43868. private _onPointerUpHandlerRef;
  43869. private _onResize;
  43870. /**
  43871. * Creates a new virtual joystick
  43872. * @param leftJoystick defines that the joystick is for left hand (false by default)
  43873. */
  43874. constructor(leftJoystick?: boolean);
  43875. /**
  43876. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  43877. * @param newJoystickSensibility defines the new sensibility
  43878. */
  43879. setJoystickSensibility(newJoystickSensibility: number): void;
  43880. private _onPointerDown;
  43881. private _onPointerMove;
  43882. private _onPointerUp;
  43883. /**
  43884. * Change the color of the virtual joystick
  43885. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  43886. */
  43887. setJoystickColor(newColor: string): void;
  43888. /**
  43889. * Defines a callback to call when the joystick is touched
  43890. * @param action defines the callback
  43891. */
  43892. setActionOnTouch(action: () => any): void;
  43893. /**
  43894. * Defines which axis you'd like to control for left & right
  43895. * @param axis defines the axis to use
  43896. */
  43897. setAxisForLeftRight(axis: JoystickAxis): void;
  43898. /**
  43899. * Defines which axis you'd like to control for up & down
  43900. * @param axis defines the axis to use
  43901. */
  43902. setAxisForUpDown(axis: JoystickAxis): void;
  43903. private _drawVirtualJoystick;
  43904. /**
  43905. * Release internal HTML canvas
  43906. */
  43907. releaseCanvas(): void;
  43908. }
  43909. }
  43910. declare module BABYLON {
  43911. interface FreeCameraInputsManager {
  43912. /**
  43913. * Add virtual joystick input support to the input manager.
  43914. * @returns the current input manager
  43915. */
  43916. addVirtualJoystick(): FreeCameraInputsManager;
  43917. }
  43918. /**
  43919. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  43920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43921. */
  43922. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  43923. /**
  43924. * Defines the camera the input is attached to.
  43925. */
  43926. camera: FreeCamera;
  43927. private _leftjoystick;
  43928. private _rightjoystick;
  43929. /**
  43930. * Gets the left stick of the virtual joystick.
  43931. * @returns The virtual Joystick
  43932. */
  43933. getLeftJoystick(): VirtualJoystick;
  43934. /**
  43935. * Gets the right stick of the virtual joystick.
  43936. * @returns The virtual Joystick
  43937. */
  43938. getRightJoystick(): VirtualJoystick;
  43939. /**
  43940. * Update the current camera state depending on the inputs that have been used this frame.
  43941. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43942. */
  43943. checkInputs(): void;
  43944. /**
  43945. * Attach the input controls to a specific dom element to get the input from.
  43946. * @param element Defines the element the controls should be listened from
  43947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43948. */
  43949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43950. /**
  43951. * Detach the current controls from the specified dom element.
  43952. * @param element Defines the element to stop listening the inputs from
  43953. */
  43954. detachControl(element: Nullable<HTMLElement>): void;
  43955. /**
  43956. * Gets the class name of the current intput.
  43957. * @returns the class name
  43958. */
  43959. getClassName(): string;
  43960. /**
  43961. * Get the friendly name associated with the input class.
  43962. * @returns the input friendly name
  43963. */
  43964. getSimpleName(): string;
  43965. }
  43966. }
  43967. declare module BABYLON {
  43968. /**
  43969. * This represents a FPS type of camera controlled by touch.
  43970. * This is like a universal camera minus the Gamepad controls.
  43971. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43972. */
  43973. export class TouchCamera extends FreeCamera {
  43974. /**
  43975. * Defines the touch sensibility for rotation.
  43976. * The higher the faster.
  43977. */
  43978. get touchAngularSensibility(): number;
  43979. set touchAngularSensibility(value: number);
  43980. /**
  43981. * Defines the touch sensibility for move.
  43982. * The higher the faster.
  43983. */
  43984. get touchMoveSensibility(): number;
  43985. set touchMoveSensibility(value: number);
  43986. /**
  43987. * Instantiates a new touch camera.
  43988. * This represents a FPS type of camera controlled by touch.
  43989. * This is like a universal camera minus the Gamepad controls.
  43990. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43991. * @param name Define the name of the camera in the scene
  43992. * @param position Define the start position of the camera in the scene
  43993. * @param scene Define the scene the camera belongs to
  43994. */
  43995. constructor(name: string, position: Vector3, scene: Scene);
  43996. /**
  43997. * Gets the current object class name.
  43998. * @return the class name
  43999. */
  44000. getClassName(): string;
  44001. /** @hidden */
  44002. _setupInputs(): void;
  44003. }
  44004. }
  44005. declare module BABYLON {
  44006. /**
  44007. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44008. * being tilted forward or back and left or right.
  44009. */
  44010. export class DeviceOrientationCamera extends FreeCamera {
  44011. private _initialQuaternion;
  44012. private _quaternionCache;
  44013. private _tmpDragQuaternion;
  44014. private _disablePointerInputWhenUsingDeviceOrientation;
  44015. /**
  44016. * Creates a new device orientation camera
  44017. * @param name The name of the camera
  44018. * @param position The start position camera
  44019. * @param scene The scene the camera belongs to
  44020. */
  44021. constructor(name: string, position: Vector3, scene: Scene);
  44022. /**
  44023. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44024. */
  44025. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44026. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44027. private _dragFactor;
  44028. /**
  44029. * Enabled turning on the y axis when the orientation sensor is active
  44030. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44031. */
  44032. enableHorizontalDragging(dragFactor?: number): void;
  44033. /**
  44034. * Gets the current instance class name ("DeviceOrientationCamera").
  44035. * This helps avoiding instanceof at run time.
  44036. * @returns the class name
  44037. */
  44038. getClassName(): string;
  44039. /**
  44040. * @hidden
  44041. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44042. */
  44043. _checkInputs(): void;
  44044. /**
  44045. * Reset the camera to its default orientation on the specified axis only.
  44046. * @param axis The axis to reset
  44047. */
  44048. resetToCurrentRotation(axis?: Axis): void;
  44049. }
  44050. }
  44051. declare module BABYLON {
  44052. /**
  44053. * Defines supported buttons for XBox360 compatible gamepads
  44054. */
  44055. export enum Xbox360Button {
  44056. /** A */
  44057. A = 0,
  44058. /** B */
  44059. B = 1,
  44060. /** X */
  44061. X = 2,
  44062. /** Y */
  44063. Y = 3,
  44064. /** Left button */
  44065. LB = 4,
  44066. /** Right button */
  44067. RB = 5,
  44068. /** Back */
  44069. Back = 8,
  44070. /** Start */
  44071. Start = 9,
  44072. /** Left stick */
  44073. LeftStick = 10,
  44074. /** Right stick */
  44075. RightStick = 11
  44076. }
  44077. /** Defines values for XBox360 DPad */
  44078. export enum Xbox360Dpad {
  44079. /** Up */
  44080. Up = 12,
  44081. /** Down */
  44082. Down = 13,
  44083. /** Left */
  44084. Left = 14,
  44085. /** Right */
  44086. Right = 15
  44087. }
  44088. /**
  44089. * Defines a XBox360 gamepad
  44090. */
  44091. export class Xbox360Pad extends Gamepad {
  44092. private _leftTrigger;
  44093. private _rightTrigger;
  44094. private _onlefttriggerchanged;
  44095. private _onrighttriggerchanged;
  44096. private _onbuttondown;
  44097. private _onbuttonup;
  44098. private _ondpaddown;
  44099. private _ondpadup;
  44100. /** Observable raised when a button is pressed */
  44101. onButtonDownObservable: Observable<Xbox360Button>;
  44102. /** Observable raised when a button is released */
  44103. onButtonUpObservable: Observable<Xbox360Button>;
  44104. /** Observable raised when a pad is pressed */
  44105. onPadDownObservable: Observable<Xbox360Dpad>;
  44106. /** Observable raised when a pad is released */
  44107. onPadUpObservable: Observable<Xbox360Dpad>;
  44108. private _buttonA;
  44109. private _buttonB;
  44110. private _buttonX;
  44111. private _buttonY;
  44112. private _buttonBack;
  44113. private _buttonStart;
  44114. private _buttonLB;
  44115. private _buttonRB;
  44116. private _buttonLeftStick;
  44117. private _buttonRightStick;
  44118. private _dPadUp;
  44119. private _dPadDown;
  44120. private _dPadLeft;
  44121. private _dPadRight;
  44122. private _isXboxOnePad;
  44123. /**
  44124. * Creates a new XBox360 gamepad object
  44125. * @param id defines the id of this gamepad
  44126. * @param index defines its index
  44127. * @param gamepad defines the internal HTML gamepad object
  44128. * @param xboxOne defines if it is a XBox One gamepad
  44129. */
  44130. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44131. /**
  44132. * Defines the callback to call when left trigger is pressed
  44133. * @param callback defines the callback to use
  44134. */
  44135. onlefttriggerchanged(callback: (value: number) => void): void;
  44136. /**
  44137. * Defines the callback to call when right trigger is pressed
  44138. * @param callback defines the callback to use
  44139. */
  44140. onrighttriggerchanged(callback: (value: number) => void): void;
  44141. /**
  44142. * Gets the left trigger value
  44143. */
  44144. get leftTrigger(): number;
  44145. /**
  44146. * Sets the left trigger value
  44147. */
  44148. set leftTrigger(newValue: number);
  44149. /**
  44150. * Gets the right trigger value
  44151. */
  44152. get rightTrigger(): number;
  44153. /**
  44154. * Sets the right trigger value
  44155. */
  44156. set rightTrigger(newValue: number);
  44157. /**
  44158. * Defines the callback to call when a button is pressed
  44159. * @param callback defines the callback to use
  44160. */
  44161. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44162. /**
  44163. * Defines the callback to call when a button is released
  44164. * @param callback defines the callback to use
  44165. */
  44166. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44167. /**
  44168. * Defines the callback to call when a pad is pressed
  44169. * @param callback defines the callback to use
  44170. */
  44171. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44172. /**
  44173. * Defines the callback to call when a pad is released
  44174. * @param callback defines the callback to use
  44175. */
  44176. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44177. private _setButtonValue;
  44178. private _setDPadValue;
  44179. /**
  44180. * Gets the value of the `A` button
  44181. */
  44182. get buttonA(): number;
  44183. /**
  44184. * Sets the value of the `A` button
  44185. */
  44186. set buttonA(value: number);
  44187. /**
  44188. * Gets the value of the `B` button
  44189. */
  44190. get buttonB(): number;
  44191. /**
  44192. * Sets the value of the `B` button
  44193. */
  44194. set buttonB(value: number);
  44195. /**
  44196. * Gets the value of the `X` button
  44197. */
  44198. get buttonX(): number;
  44199. /**
  44200. * Sets the value of the `X` button
  44201. */
  44202. set buttonX(value: number);
  44203. /**
  44204. * Gets the value of the `Y` button
  44205. */
  44206. get buttonY(): number;
  44207. /**
  44208. * Sets the value of the `Y` button
  44209. */
  44210. set buttonY(value: number);
  44211. /**
  44212. * Gets the value of the `Start` button
  44213. */
  44214. get buttonStart(): number;
  44215. /**
  44216. * Sets the value of the `Start` button
  44217. */
  44218. set buttonStart(value: number);
  44219. /**
  44220. * Gets the value of the `Back` button
  44221. */
  44222. get buttonBack(): number;
  44223. /**
  44224. * Sets the value of the `Back` button
  44225. */
  44226. set buttonBack(value: number);
  44227. /**
  44228. * Gets the value of the `Left` button
  44229. */
  44230. get buttonLB(): number;
  44231. /**
  44232. * Sets the value of the `Left` button
  44233. */
  44234. set buttonLB(value: number);
  44235. /**
  44236. * Gets the value of the `Right` button
  44237. */
  44238. get buttonRB(): number;
  44239. /**
  44240. * Sets the value of the `Right` button
  44241. */
  44242. set buttonRB(value: number);
  44243. /**
  44244. * Gets the value of the Left joystick
  44245. */
  44246. get buttonLeftStick(): number;
  44247. /**
  44248. * Sets the value of the Left joystick
  44249. */
  44250. set buttonLeftStick(value: number);
  44251. /**
  44252. * Gets the value of the Right joystick
  44253. */
  44254. get buttonRightStick(): number;
  44255. /**
  44256. * Sets the value of the Right joystick
  44257. */
  44258. set buttonRightStick(value: number);
  44259. /**
  44260. * Gets the value of D-pad up
  44261. */
  44262. get dPadUp(): number;
  44263. /**
  44264. * Sets the value of D-pad up
  44265. */
  44266. set dPadUp(value: number);
  44267. /**
  44268. * Gets the value of D-pad down
  44269. */
  44270. get dPadDown(): number;
  44271. /**
  44272. * Sets the value of D-pad down
  44273. */
  44274. set dPadDown(value: number);
  44275. /**
  44276. * Gets the value of D-pad left
  44277. */
  44278. get dPadLeft(): number;
  44279. /**
  44280. * Sets the value of D-pad left
  44281. */
  44282. set dPadLeft(value: number);
  44283. /**
  44284. * Gets the value of D-pad right
  44285. */
  44286. get dPadRight(): number;
  44287. /**
  44288. * Sets the value of D-pad right
  44289. */
  44290. set dPadRight(value: number);
  44291. /**
  44292. * Force the gamepad to synchronize with device values
  44293. */
  44294. update(): void;
  44295. /**
  44296. * Disposes the gamepad
  44297. */
  44298. dispose(): void;
  44299. }
  44300. }
  44301. declare module BABYLON {
  44302. /**
  44303. * Defines supported buttons for DualShock compatible gamepads
  44304. */
  44305. export enum DualShockButton {
  44306. /** Cross */
  44307. Cross = 0,
  44308. /** Circle */
  44309. Circle = 1,
  44310. /** Square */
  44311. Square = 2,
  44312. /** Triangle */
  44313. Triangle = 3,
  44314. /** L1 */
  44315. L1 = 4,
  44316. /** R1 */
  44317. R1 = 5,
  44318. /** Share */
  44319. Share = 8,
  44320. /** Options */
  44321. Options = 9,
  44322. /** Left stick */
  44323. LeftStick = 10,
  44324. /** Right stick */
  44325. RightStick = 11
  44326. }
  44327. /** Defines values for DualShock DPad */
  44328. export enum DualShockDpad {
  44329. /** Up */
  44330. Up = 12,
  44331. /** Down */
  44332. Down = 13,
  44333. /** Left */
  44334. Left = 14,
  44335. /** Right */
  44336. Right = 15
  44337. }
  44338. /**
  44339. * Defines a DualShock gamepad
  44340. */
  44341. export class DualShockPad extends Gamepad {
  44342. private _leftTrigger;
  44343. private _rightTrigger;
  44344. private _onlefttriggerchanged;
  44345. private _onrighttriggerchanged;
  44346. private _onbuttondown;
  44347. private _onbuttonup;
  44348. private _ondpaddown;
  44349. private _ondpadup;
  44350. /** Observable raised when a button is pressed */
  44351. onButtonDownObservable: Observable<DualShockButton>;
  44352. /** Observable raised when a button is released */
  44353. onButtonUpObservable: Observable<DualShockButton>;
  44354. /** Observable raised when a pad is pressed */
  44355. onPadDownObservable: Observable<DualShockDpad>;
  44356. /** Observable raised when a pad is released */
  44357. onPadUpObservable: Observable<DualShockDpad>;
  44358. private _buttonCross;
  44359. private _buttonCircle;
  44360. private _buttonSquare;
  44361. private _buttonTriangle;
  44362. private _buttonShare;
  44363. private _buttonOptions;
  44364. private _buttonL1;
  44365. private _buttonR1;
  44366. private _buttonLeftStick;
  44367. private _buttonRightStick;
  44368. private _dPadUp;
  44369. private _dPadDown;
  44370. private _dPadLeft;
  44371. private _dPadRight;
  44372. /**
  44373. * Creates a new DualShock gamepad object
  44374. * @param id defines the id of this gamepad
  44375. * @param index defines its index
  44376. * @param gamepad defines the internal HTML gamepad object
  44377. */
  44378. constructor(id: string, index: number, gamepad: any);
  44379. /**
  44380. * Defines the callback to call when left trigger is pressed
  44381. * @param callback defines the callback to use
  44382. */
  44383. onlefttriggerchanged(callback: (value: number) => void): void;
  44384. /**
  44385. * Defines the callback to call when right trigger is pressed
  44386. * @param callback defines the callback to use
  44387. */
  44388. onrighttriggerchanged(callback: (value: number) => void): void;
  44389. /**
  44390. * Gets the left trigger value
  44391. */
  44392. get leftTrigger(): number;
  44393. /**
  44394. * Sets the left trigger value
  44395. */
  44396. set leftTrigger(newValue: number);
  44397. /**
  44398. * Gets the right trigger value
  44399. */
  44400. get rightTrigger(): number;
  44401. /**
  44402. * Sets the right trigger value
  44403. */
  44404. set rightTrigger(newValue: number);
  44405. /**
  44406. * Defines the callback to call when a button is pressed
  44407. * @param callback defines the callback to use
  44408. */
  44409. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44410. /**
  44411. * Defines the callback to call when a button is released
  44412. * @param callback defines the callback to use
  44413. */
  44414. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44415. /**
  44416. * Defines the callback to call when a pad is pressed
  44417. * @param callback defines the callback to use
  44418. */
  44419. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44420. /**
  44421. * Defines the callback to call when a pad is released
  44422. * @param callback defines the callback to use
  44423. */
  44424. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44425. private _setButtonValue;
  44426. private _setDPadValue;
  44427. /**
  44428. * Gets the value of the `Cross` button
  44429. */
  44430. get buttonCross(): number;
  44431. /**
  44432. * Sets the value of the `Cross` button
  44433. */
  44434. set buttonCross(value: number);
  44435. /**
  44436. * Gets the value of the `Circle` button
  44437. */
  44438. get buttonCircle(): number;
  44439. /**
  44440. * Sets the value of the `Circle` button
  44441. */
  44442. set buttonCircle(value: number);
  44443. /**
  44444. * Gets the value of the `Square` button
  44445. */
  44446. get buttonSquare(): number;
  44447. /**
  44448. * Sets the value of the `Square` button
  44449. */
  44450. set buttonSquare(value: number);
  44451. /**
  44452. * Gets the value of the `Triangle` button
  44453. */
  44454. get buttonTriangle(): number;
  44455. /**
  44456. * Sets the value of the `Triangle` button
  44457. */
  44458. set buttonTriangle(value: number);
  44459. /**
  44460. * Gets the value of the `Options` button
  44461. */
  44462. get buttonOptions(): number;
  44463. /**
  44464. * Sets the value of the `Options` button
  44465. */
  44466. set buttonOptions(value: number);
  44467. /**
  44468. * Gets the value of the `Share` button
  44469. */
  44470. get buttonShare(): number;
  44471. /**
  44472. * Sets the value of the `Share` button
  44473. */
  44474. set buttonShare(value: number);
  44475. /**
  44476. * Gets the value of the `L1` button
  44477. */
  44478. get buttonL1(): number;
  44479. /**
  44480. * Sets the value of the `L1` button
  44481. */
  44482. set buttonL1(value: number);
  44483. /**
  44484. * Gets the value of the `R1` button
  44485. */
  44486. get buttonR1(): number;
  44487. /**
  44488. * Sets the value of the `R1` button
  44489. */
  44490. set buttonR1(value: number);
  44491. /**
  44492. * Gets the value of the Left joystick
  44493. */
  44494. get buttonLeftStick(): number;
  44495. /**
  44496. * Sets the value of the Left joystick
  44497. */
  44498. set buttonLeftStick(value: number);
  44499. /**
  44500. * Gets the value of the Right joystick
  44501. */
  44502. get buttonRightStick(): number;
  44503. /**
  44504. * Sets the value of the Right joystick
  44505. */
  44506. set buttonRightStick(value: number);
  44507. /**
  44508. * Gets the value of D-pad up
  44509. */
  44510. get dPadUp(): number;
  44511. /**
  44512. * Sets the value of D-pad up
  44513. */
  44514. set dPadUp(value: number);
  44515. /**
  44516. * Gets the value of D-pad down
  44517. */
  44518. get dPadDown(): number;
  44519. /**
  44520. * Sets the value of D-pad down
  44521. */
  44522. set dPadDown(value: number);
  44523. /**
  44524. * Gets the value of D-pad left
  44525. */
  44526. get dPadLeft(): number;
  44527. /**
  44528. * Sets the value of D-pad left
  44529. */
  44530. set dPadLeft(value: number);
  44531. /**
  44532. * Gets the value of D-pad right
  44533. */
  44534. get dPadRight(): number;
  44535. /**
  44536. * Sets the value of D-pad right
  44537. */
  44538. set dPadRight(value: number);
  44539. /**
  44540. * Force the gamepad to synchronize with device values
  44541. */
  44542. update(): void;
  44543. /**
  44544. * Disposes the gamepad
  44545. */
  44546. dispose(): void;
  44547. }
  44548. }
  44549. declare module BABYLON {
  44550. /**
  44551. * Manager for handling gamepads
  44552. */
  44553. export class GamepadManager {
  44554. private _scene?;
  44555. private _babylonGamepads;
  44556. private _oneGamepadConnected;
  44557. /** @hidden */
  44558. _isMonitoring: boolean;
  44559. private _gamepadEventSupported;
  44560. private _gamepadSupport?;
  44561. /**
  44562. * observable to be triggered when the gamepad controller has been connected
  44563. */
  44564. onGamepadConnectedObservable: Observable<Gamepad>;
  44565. /**
  44566. * observable to be triggered when the gamepad controller has been disconnected
  44567. */
  44568. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44569. private _onGamepadConnectedEvent;
  44570. private _onGamepadDisconnectedEvent;
  44571. /**
  44572. * Initializes the gamepad manager
  44573. * @param _scene BabylonJS scene
  44574. */
  44575. constructor(_scene?: Scene | undefined);
  44576. /**
  44577. * The gamepads in the game pad manager
  44578. */
  44579. get gamepads(): Gamepad[];
  44580. /**
  44581. * Get the gamepad controllers based on type
  44582. * @param type The type of gamepad controller
  44583. * @returns Nullable gamepad
  44584. */
  44585. getGamepadByType(type?: number): Nullable<Gamepad>;
  44586. /**
  44587. * Disposes the gamepad manager
  44588. */
  44589. dispose(): void;
  44590. private _addNewGamepad;
  44591. private _startMonitoringGamepads;
  44592. private _stopMonitoringGamepads;
  44593. /** @hidden */
  44594. _checkGamepadsStatus(): void;
  44595. private _updateGamepadObjects;
  44596. }
  44597. }
  44598. declare module BABYLON {
  44599. interface Scene {
  44600. /** @hidden */
  44601. _gamepadManager: Nullable<GamepadManager>;
  44602. /**
  44603. * Gets the gamepad manager associated with the scene
  44604. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44605. */
  44606. gamepadManager: GamepadManager;
  44607. }
  44608. /**
  44609. * Interface representing a free camera inputs manager
  44610. */
  44611. interface FreeCameraInputsManager {
  44612. /**
  44613. * Adds gamepad input support to the FreeCameraInputsManager.
  44614. * @returns the FreeCameraInputsManager
  44615. */
  44616. addGamepad(): FreeCameraInputsManager;
  44617. }
  44618. /**
  44619. * Interface representing an arc rotate camera inputs manager
  44620. */
  44621. interface ArcRotateCameraInputsManager {
  44622. /**
  44623. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44624. * @returns the camera inputs manager
  44625. */
  44626. addGamepad(): ArcRotateCameraInputsManager;
  44627. }
  44628. /**
  44629. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44630. */
  44631. export class GamepadSystemSceneComponent implements ISceneComponent {
  44632. /**
  44633. * The component name helpfull to identify the component in the list of scene components.
  44634. */
  44635. readonly name: string;
  44636. /**
  44637. * The scene the component belongs to.
  44638. */
  44639. scene: Scene;
  44640. /**
  44641. * Creates a new instance of the component for the given scene
  44642. * @param scene Defines the scene to register the component in
  44643. */
  44644. constructor(scene: Scene);
  44645. /**
  44646. * Registers the component in a given scene
  44647. */
  44648. register(): void;
  44649. /**
  44650. * Rebuilds the elements related to this component in case of
  44651. * context lost for instance.
  44652. */
  44653. rebuild(): void;
  44654. /**
  44655. * Disposes the component and the associated ressources
  44656. */
  44657. dispose(): void;
  44658. private _beforeCameraUpdate;
  44659. }
  44660. }
  44661. declare module BABYLON {
  44662. /**
  44663. * 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,
  44664. * which still works and will still be found in many Playgrounds.
  44665. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44666. */
  44667. export class UniversalCamera extends TouchCamera {
  44668. /**
  44669. * Defines the gamepad rotation sensiblity.
  44670. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44671. */
  44672. get gamepadAngularSensibility(): number;
  44673. set gamepadAngularSensibility(value: number);
  44674. /**
  44675. * Defines the gamepad move sensiblity.
  44676. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44677. */
  44678. get gamepadMoveSensibility(): number;
  44679. set gamepadMoveSensibility(value: number);
  44680. /**
  44681. * 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,
  44682. * which still works and will still be found in many Playgrounds.
  44683. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44684. * @param name Define the name of the camera in the scene
  44685. * @param position Define the start position of the camera in the scene
  44686. * @param scene Define the scene the camera belongs to
  44687. */
  44688. constructor(name: string, position: Vector3, scene: Scene);
  44689. /**
  44690. * Gets the current object class name.
  44691. * @return the class name
  44692. */
  44693. getClassName(): string;
  44694. }
  44695. }
  44696. declare module BABYLON {
  44697. /**
  44698. * This represents a FPS type of camera. This is only here for back compat purpose.
  44699. * Please use the UniversalCamera instead as both are identical.
  44700. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44701. */
  44702. export class GamepadCamera extends UniversalCamera {
  44703. /**
  44704. * Instantiates a new Gamepad Camera
  44705. * This represents a FPS type of camera. This is only here for back compat purpose.
  44706. * Please use the UniversalCamera instead as both are identical.
  44707. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44708. * @param name Define the name of the camera in the scene
  44709. * @param position Define the start position of the camera in the scene
  44710. * @param scene Define the scene the camera belongs to
  44711. */
  44712. constructor(name: string, position: Vector3, scene: Scene);
  44713. /**
  44714. * Gets the current object class name.
  44715. * @return the class name
  44716. */
  44717. getClassName(): string;
  44718. }
  44719. }
  44720. declare module BABYLON {
  44721. /** @hidden */
  44722. export var passPixelShader: {
  44723. name: string;
  44724. shader: string;
  44725. };
  44726. }
  44727. declare module BABYLON {
  44728. /** @hidden */
  44729. export var passCubePixelShader: {
  44730. name: string;
  44731. shader: string;
  44732. };
  44733. }
  44734. declare module BABYLON {
  44735. /**
  44736. * PassPostProcess which produces an output the same as it's input
  44737. */
  44738. export class PassPostProcess extends PostProcess {
  44739. /**
  44740. * Creates the PassPostProcess
  44741. * @param name The name of the effect.
  44742. * @param options The required width/height ratio to downsize to before computing the render pass.
  44743. * @param camera The camera to apply the render pass to.
  44744. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44745. * @param engine The engine which the post process will be applied. (default: current engine)
  44746. * @param reusable If the post process can be reused on the same frame. (default: false)
  44747. * @param textureType The type of texture to be used when performing the post processing.
  44748. * @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)
  44749. */
  44750. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44751. }
  44752. /**
  44753. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  44754. */
  44755. export class PassCubePostProcess extends PostProcess {
  44756. private _face;
  44757. /**
  44758. * Gets or sets the cube face to display.
  44759. * * 0 is +X
  44760. * * 1 is -X
  44761. * * 2 is +Y
  44762. * * 3 is -Y
  44763. * * 4 is +Z
  44764. * * 5 is -Z
  44765. */
  44766. get face(): number;
  44767. set face(value: number);
  44768. /**
  44769. * Creates the PassCubePostProcess
  44770. * @param name The name of the effect.
  44771. * @param options The required width/height ratio to downsize to before computing the render pass.
  44772. * @param camera The camera to apply the render pass to.
  44773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  44774. * @param engine The engine which the post process will be applied. (default: current engine)
  44775. * @param reusable If the post process can be reused on the same frame. (default: false)
  44776. * @param textureType The type of texture to be used when performing the post processing.
  44777. * @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)
  44778. */
  44779. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  44780. }
  44781. }
  44782. declare module BABYLON {
  44783. /** @hidden */
  44784. export var anaglyphPixelShader: {
  44785. name: string;
  44786. shader: string;
  44787. };
  44788. }
  44789. declare module BABYLON {
  44790. /**
  44791. * Postprocess used to generate anaglyphic rendering
  44792. */
  44793. export class AnaglyphPostProcess extends PostProcess {
  44794. private _passedProcess;
  44795. /**
  44796. * Creates a new AnaglyphPostProcess
  44797. * @param name defines postprocess name
  44798. * @param options defines creation options or target ratio scale
  44799. * @param rigCameras defines cameras using this postprocess
  44800. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  44801. * @param engine defines hosting engine
  44802. * @param reusable defines if the postprocess will be reused multiple times per frame
  44803. */
  44804. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  44805. }
  44806. }
  44807. declare module BABYLON {
  44808. /**
  44809. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  44810. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44811. */
  44812. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  44813. /**
  44814. * Creates a new AnaglyphArcRotateCamera
  44815. * @param name defines camera name
  44816. * @param alpha defines alpha angle (in radians)
  44817. * @param beta defines beta angle (in radians)
  44818. * @param radius defines radius
  44819. * @param target defines camera target
  44820. * @param interaxialDistance defines distance between each color axis
  44821. * @param scene defines the hosting scene
  44822. */
  44823. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  44824. /**
  44825. * Gets camera class name
  44826. * @returns AnaglyphArcRotateCamera
  44827. */
  44828. getClassName(): string;
  44829. }
  44830. }
  44831. declare module BABYLON {
  44832. /**
  44833. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  44834. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44835. */
  44836. export class AnaglyphFreeCamera extends FreeCamera {
  44837. /**
  44838. * Creates a new AnaglyphFreeCamera
  44839. * @param name defines camera name
  44840. * @param position defines initial position
  44841. * @param interaxialDistance defines distance between each color axis
  44842. * @param scene defines the hosting scene
  44843. */
  44844. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44845. /**
  44846. * Gets camera class name
  44847. * @returns AnaglyphFreeCamera
  44848. */
  44849. getClassName(): string;
  44850. }
  44851. }
  44852. declare module BABYLON {
  44853. /**
  44854. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  44855. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44856. */
  44857. export class AnaglyphGamepadCamera extends GamepadCamera {
  44858. /**
  44859. * Creates a new AnaglyphGamepadCamera
  44860. * @param name defines camera name
  44861. * @param position defines initial position
  44862. * @param interaxialDistance defines distance between each color axis
  44863. * @param scene defines the hosting scene
  44864. */
  44865. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44866. /**
  44867. * Gets camera class name
  44868. * @returns AnaglyphGamepadCamera
  44869. */
  44870. getClassName(): string;
  44871. }
  44872. }
  44873. declare module BABYLON {
  44874. /**
  44875. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  44876. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  44877. */
  44878. export class AnaglyphUniversalCamera extends UniversalCamera {
  44879. /**
  44880. * Creates a new AnaglyphUniversalCamera
  44881. * @param name defines camera name
  44882. * @param position defines initial position
  44883. * @param interaxialDistance defines distance between each color axis
  44884. * @param scene defines the hosting scene
  44885. */
  44886. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  44887. /**
  44888. * Gets camera class name
  44889. * @returns AnaglyphUniversalCamera
  44890. */
  44891. getClassName(): string;
  44892. }
  44893. }
  44894. declare module BABYLON {
  44895. /**
  44896. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  44897. * @see http://doc.babylonjs.com/features/cameras
  44898. */
  44899. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  44900. /**
  44901. * Creates a new StereoscopicArcRotateCamera
  44902. * @param name defines camera name
  44903. * @param alpha defines alpha angle (in radians)
  44904. * @param beta defines beta angle (in radians)
  44905. * @param radius defines radius
  44906. * @param target defines camera target
  44907. * @param interaxialDistance defines distance between each color axis
  44908. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44909. * @param scene defines the hosting scene
  44910. */
  44911. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44912. /**
  44913. * Gets camera class name
  44914. * @returns StereoscopicArcRotateCamera
  44915. */
  44916. getClassName(): string;
  44917. }
  44918. }
  44919. declare module BABYLON {
  44920. /**
  44921. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  44922. * @see http://doc.babylonjs.com/features/cameras
  44923. */
  44924. export class StereoscopicFreeCamera extends FreeCamera {
  44925. /**
  44926. * Creates a new StereoscopicFreeCamera
  44927. * @param name defines camera name
  44928. * @param position defines initial position
  44929. * @param interaxialDistance defines distance between each color axis
  44930. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44931. * @param scene defines the hosting scene
  44932. */
  44933. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44934. /**
  44935. * Gets camera class name
  44936. * @returns StereoscopicFreeCamera
  44937. */
  44938. getClassName(): string;
  44939. }
  44940. }
  44941. declare module BABYLON {
  44942. /**
  44943. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  44944. * @see http://doc.babylonjs.com/features/cameras
  44945. */
  44946. export class StereoscopicGamepadCamera extends GamepadCamera {
  44947. /**
  44948. * Creates a new StereoscopicGamepadCamera
  44949. * @param name defines camera name
  44950. * @param position defines initial position
  44951. * @param interaxialDistance defines distance between each color axis
  44952. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44953. * @param scene defines the hosting scene
  44954. */
  44955. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44956. /**
  44957. * Gets camera class name
  44958. * @returns StereoscopicGamepadCamera
  44959. */
  44960. getClassName(): string;
  44961. }
  44962. }
  44963. declare module BABYLON {
  44964. /**
  44965. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  44966. * @see http://doc.babylonjs.com/features/cameras
  44967. */
  44968. export class StereoscopicUniversalCamera extends UniversalCamera {
  44969. /**
  44970. * Creates a new StereoscopicUniversalCamera
  44971. * @param name defines camera name
  44972. * @param position defines initial position
  44973. * @param interaxialDistance defines distance between each color axis
  44974. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  44975. * @param scene defines the hosting scene
  44976. */
  44977. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  44978. /**
  44979. * Gets camera class name
  44980. * @returns StereoscopicUniversalCamera
  44981. */
  44982. getClassName(): string;
  44983. }
  44984. }
  44985. declare module BABYLON {
  44986. /**
  44987. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  44988. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44989. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44990. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44991. */
  44992. export class VirtualJoysticksCamera extends FreeCamera {
  44993. /**
  44994. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  44995. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  44996. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  44997. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  44998. * @param name Define the name of the camera in the scene
  44999. * @param position Define the start position of the camera in the scene
  45000. * @param scene Define the scene the camera belongs to
  45001. */
  45002. constructor(name: string, position: Vector3, scene: Scene);
  45003. /**
  45004. * Gets the current object class name.
  45005. * @return the class name
  45006. */
  45007. getClassName(): string;
  45008. }
  45009. }
  45010. declare module BABYLON {
  45011. /**
  45012. * This represents all the required metrics to create a VR camera.
  45013. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45014. */
  45015. export class VRCameraMetrics {
  45016. /**
  45017. * Define the horizontal resolution off the screen.
  45018. */
  45019. hResolution: number;
  45020. /**
  45021. * Define the vertical resolution off the screen.
  45022. */
  45023. vResolution: number;
  45024. /**
  45025. * Define the horizontal screen size.
  45026. */
  45027. hScreenSize: number;
  45028. /**
  45029. * Define the vertical screen size.
  45030. */
  45031. vScreenSize: number;
  45032. /**
  45033. * Define the vertical screen center position.
  45034. */
  45035. vScreenCenter: number;
  45036. /**
  45037. * Define the distance of the eyes to the screen.
  45038. */
  45039. eyeToScreenDistance: number;
  45040. /**
  45041. * Define the distance between both lenses
  45042. */
  45043. lensSeparationDistance: number;
  45044. /**
  45045. * Define the distance between both viewer's eyes.
  45046. */
  45047. interpupillaryDistance: number;
  45048. /**
  45049. * Define the distortion factor of the VR postprocess.
  45050. * Please, touch with care.
  45051. */
  45052. distortionK: number[];
  45053. /**
  45054. * Define the chromatic aberration correction factors for the VR post process.
  45055. */
  45056. chromaAbCorrection: number[];
  45057. /**
  45058. * Define the scale factor of the post process.
  45059. * The smaller the better but the slower.
  45060. */
  45061. postProcessScaleFactor: number;
  45062. /**
  45063. * Define an offset for the lens center.
  45064. */
  45065. lensCenterOffset: number;
  45066. /**
  45067. * Define if the current vr camera should compensate the distortion of the lense or not.
  45068. */
  45069. compensateDistortion: boolean;
  45070. /**
  45071. * Defines if multiview should be enabled when rendering (Default: false)
  45072. */
  45073. multiviewEnabled: boolean;
  45074. /**
  45075. * Gets the rendering aspect ratio based on the provided resolutions.
  45076. */
  45077. get aspectRatio(): number;
  45078. /**
  45079. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45080. */
  45081. get aspectRatioFov(): number;
  45082. /**
  45083. * @hidden
  45084. */
  45085. get leftHMatrix(): Matrix;
  45086. /**
  45087. * @hidden
  45088. */
  45089. get rightHMatrix(): Matrix;
  45090. /**
  45091. * @hidden
  45092. */
  45093. get leftPreViewMatrix(): Matrix;
  45094. /**
  45095. * @hidden
  45096. */
  45097. get rightPreViewMatrix(): Matrix;
  45098. /**
  45099. * Get the default VRMetrics based on the most generic setup.
  45100. * @returns the default vr metrics
  45101. */
  45102. static GetDefault(): VRCameraMetrics;
  45103. }
  45104. }
  45105. declare module BABYLON {
  45106. /** @hidden */
  45107. export var vrDistortionCorrectionPixelShader: {
  45108. name: string;
  45109. shader: string;
  45110. };
  45111. }
  45112. declare module BABYLON {
  45113. /**
  45114. * VRDistortionCorrectionPostProcess used for mobile VR
  45115. */
  45116. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45117. private _isRightEye;
  45118. private _distortionFactors;
  45119. private _postProcessScaleFactor;
  45120. private _lensCenterOffset;
  45121. private _scaleIn;
  45122. private _scaleFactor;
  45123. private _lensCenter;
  45124. /**
  45125. * Initializes the VRDistortionCorrectionPostProcess
  45126. * @param name The name of the effect.
  45127. * @param camera The camera to apply the render pass to.
  45128. * @param isRightEye If this is for the right eye distortion
  45129. * @param vrMetrics All the required metrics for the VR camera
  45130. */
  45131. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45132. }
  45133. }
  45134. declare module BABYLON {
  45135. /**
  45136. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45137. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45138. */
  45139. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45140. /**
  45141. * Creates a new VRDeviceOrientationArcRotateCamera
  45142. * @param name defines camera name
  45143. * @param alpha defines the camera rotation along the logitudinal axis
  45144. * @param beta defines the camera rotation along the latitudinal axis
  45145. * @param radius defines the camera distance from its target
  45146. * @param target defines the camera target
  45147. * @param scene defines the scene the camera belongs to
  45148. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45149. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45150. */
  45151. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45152. /**
  45153. * Gets camera class name
  45154. * @returns VRDeviceOrientationArcRotateCamera
  45155. */
  45156. getClassName(): string;
  45157. }
  45158. }
  45159. declare module BABYLON {
  45160. /**
  45161. * Camera used to simulate VR rendering (based on FreeCamera)
  45162. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45163. */
  45164. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45165. /**
  45166. * Creates a new VRDeviceOrientationFreeCamera
  45167. * @param name defines camera name
  45168. * @param position defines the start position of the camera
  45169. * @param scene defines the scene the camera belongs to
  45170. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45171. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45172. */
  45173. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45174. /**
  45175. * Gets camera class name
  45176. * @returns VRDeviceOrientationFreeCamera
  45177. */
  45178. getClassName(): string;
  45179. }
  45180. }
  45181. declare module BABYLON {
  45182. /**
  45183. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45184. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45185. */
  45186. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45187. /**
  45188. * Creates a new VRDeviceOrientationGamepadCamera
  45189. * @param name defines camera name
  45190. * @param position defines the start position of the camera
  45191. * @param scene defines the scene the camera belongs to
  45192. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45193. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45194. */
  45195. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45196. /**
  45197. * Gets camera class name
  45198. * @returns VRDeviceOrientationGamepadCamera
  45199. */
  45200. getClassName(): string;
  45201. }
  45202. }
  45203. declare module BABYLON {
  45204. /** @hidden */
  45205. export var imageProcessingPixelShader: {
  45206. name: string;
  45207. shader: string;
  45208. };
  45209. }
  45210. declare module BABYLON {
  45211. /**
  45212. * ImageProcessingPostProcess
  45213. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45214. */
  45215. export class ImageProcessingPostProcess extends PostProcess {
  45216. /**
  45217. * Default configuration related to image processing available in the PBR Material.
  45218. */
  45219. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45220. /**
  45221. * Gets the image processing configuration used either in this material.
  45222. */
  45223. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45224. /**
  45225. * Sets the Default image processing configuration used either in the this material.
  45226. *
  45227. * If sets to null, the scene one is in use.
  45228. */
  45229. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45230. /**
  45231. * Keep track of the image processing observer to allow dispose and replace.
  45232. */
  45233. private _imageProcessingObserver;
  45234. /**
  45235. * Attaches a new image processing configuration to the PBR Material.
  45236. * @param configuration
  45237. */
  45238. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45239. /**
  45240. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45241. */
  45242. get colorCurves(): Nullable<ColorCurves>;
  45243. /**
  45244. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45245. */
  45246. set colorCurves(value: Nullable<ColorCurves>);
  45247. /**
  45248. * Gets wether the color curves effect is enabled.
  45249. */
  45250. get colorCurvesEnabled(): boolean;
  45251. /**
  45252. * Sets wether the color curves effect is enabled.
  45253. */
  45254. set colorCurvesEnabled(value: boolean);
  45255. /**
  45256. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45257. */
  45258. get colorGradingTexture(): Nullable<BaseTexture>;
  45259. /**
  45260. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45261. */
  45262. set colorGradingTexture(value: Nullable<BaseTexture>);
  45263. /**
  45264. * Gets wether the color grading effect is enabled.
  45265. */
  45266. get colorGradingEnabled(): boolean;
  45267. /**
  45268. * Gets wether the color grading effect is enabled.
  45269. */
  45270. set colorGradingEnabled(value: boolean);
  45271. /**
  45272. * Gets exposure used in the effect.
  45273. */
  45274. get exposure(): number;
  45275. /**
  45276. * Sets exposure used in the effect.
  45277. */
  45278. set exposure(value: number);
  45279. /**
  45280. * Gets wether tonemapping is enabled or not.
  45281. */
  45282. get toneMappingEnabled(): boolean;
  45283. /**
  45284. * Sets wether tonemapping is enabled or not
  45285. */
  45286. set toneMappingEnabled(value: boolean);
  45287. /**
  45288. * Gets the type of tone mapping effect.
  45289. */
  45290. get toneMappingType(): number;
  45291. /**
  45292. * Sets the type of tone mapping effect.
  45293. */
  45294. set toneMappingType(value: number);
  45295. /**
  45296. * Gets contrast used in the effect.
  45297. */
  45298. get contrast(): number;
  45299. /**
  45300. * Sets contrast used in the effect.
  45301. */
  45302. set contrast(value: number);
  45303. /**
  45304. * Gets Vignette stretch size.
  45305. */
  45306. get vignetteStretch(): number;
  45307. /**
  45308. * Sets Vignette stretch size.
  45309. */
  45310. set vignetteStretch(value: number);
  45311. /**
  45312. * Gets Vignette centre X Offset.
  45313. */
  45314. get vignetteCentreX(): number;
  45315. /**
  45316. * Sets Vignette centre X Offset.
  45317. */
  45318. set vignetteCentreX(value: number);
  45319. /**
  45320. * Gets Vignette centre Y Offset.
  45321. */
  45322. get vignetteCentreY(): number;
  45323. /**
  45324. * Sets Vignette centre Y Offset.
  45325. */
  45326. set vignetteCentreY(value: number);
  45327. /**
  45328. * Gets Vignette weight or intensity of the vignette effect.
  45329. */
  45330. get vignetteWeight(): number;
  45331. /**
  45332. * Sets Vignette weight or intensity of the vignette effect.
  45333. */
  45334. set vignetteWeight(value: number);
  45335. /**
  45336. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45337. * if vignetteEnabled is set to true.
  45338. */
  45339. get vignetteColor(): Color4;
  45340. /**
  45341. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45342. * if vignetteEnabled is set to true.
  45343. */
  45344. set vignetteColor(value: Color4);
  45345. /**
  45346. * Gets Camera field of view used by the Vignette effect.
  45347. */
  45348. get vignetteCameraFov(): number;
  45349. /**
  45350. * Sets Camera field of view used by the Vignette effect.
  45351. */
  45352. set vignetteCameraFov(value: number);
  45353. /**
  45354. * Gets the vignette blend mode allowing different kind of effect.
  45355. */
  45356. get vignetteBlendMode(): number;
  45357. /**
  45358. * Sets the vignette blend mode allowing different kind of effect.
  45359. */
  45360. set vignetteBlendMode(value: number);
  45361. /**
  45362. * Gets wether the vignette effect is enabled.
  45363. */
  45364. get vignetteEnabled(): boolean;
  45365. /**
  45366. * Sets wether the vignette effect is enabled.
  45367. */
  45368. set vignetteEnabled(value: boolean);
  45369. private _fromLinearSpace;
  45370. /**
  45371. * Gets wether the input of the processing is in Gamma or Linear Space.
  45372. */
  45373. get fromLinearSpace(): boolean;
  45374. /**
  45375. * Sets wether the input of the processing is in Gamma or Linear Space.
  45376. */
  45377. set fromLinearSpace(value: boolean);
  45378. /**
  45379. * Defines cache preventing GC.
  45380. */
  45381. private _defines;
  45382. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45383. /**
  45384. * "ImageProcessingPostProcess"
  45385. * @returns "ImageProcessingPostProcess"
  45386. */
  45387. getClassName(): string;
  45388. protected _updateParameters(): void;
  45389. dispose(camera?: Camera): void;
  45390. }
  45391. }
  45392. declare module BABYLON {
  45393. /**
  45394. * Class containing static functions to help procedurally build meshes
  45395. */
  45396. export class GroundBuilder {
  45397. /**
  45398. * Creates a ground mesh
  45399. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45400. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  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 options defines the options used to create the mesh
  45404. * @param scene defines the hosting scene
  45405. * @returns the ground mesh
  45406. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45407. */
  45408. static CreateGround(name: string, options: {
  45409. width?: number;
  45410. height?: number;
  45411. subdivisions?: number;
  45412. subdivisionsX?: number;
  45413. subdivisionsY?: number;
  45414. updatable?: boolean;
  45415. }, scene: any): Mesh;
  45416. /**
  45417. * Creates a tiled ground mesh
  45418. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45419. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45420. * * 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
  45421. * * 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
  45422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45423. * @param name defines the name of the mesh
  45424. * @param options defines the options used to create the mesh
  45425. * @param scene defines the hosting scene
  45426. * @returns the tiled ground mesh
  45427. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45428. */
  45429. static CreateTiledGround(name: string, options: {
  45430. xmin: number;
  45431. zmin: number;
  45432. xmax: number;
  45433. zmax: number;
  45434. subdivisions?: {
  45435. w: number;
  45436. h: number;
  45437. };
  45438. precision?: {
  45439. w: number;
  45440. h: number;
  45441. };
  45442. updatable?: boolean;
  45443. }, scene?: Nullable<Scene>): Mesh;
  45444. /**
  45445. * Creates a ground mesh from a height map
  45446. * * The parameter `url` sets the URL of the height map image resource.
  45447. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45448. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45449. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45450. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45451. * * 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.
  45452. * * 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).
  45453. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45455. * @param name defines the name of the mesh
  45456. * @param url defines the url to the height map
  45457. * @param options defines the options used to create the mesh
  45458. * @param scene defines the hosting scene
  45459. * @returns the ground mesh
  45460. * @see https://doc.babylonjs.com/babylon101/height_map
  45461. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45462. */
  45463. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45464. width?: number;
  45465. height?: number;
  45466. subdivisions?: number;
  45467. minHeight?: number;
  45468. maxHeight?: number;
  45469. colorFilter?: Color3;
  45470. alphaFilter?: number;
  45471. updatable?: boolean;
  45472. onReady?: (mesh: GroundMesh) => void;
  45473. }, scene?: Nullable<Scene>): GroundMesh;
  45474. }
  45475. }
  45476. declare module BABYLON {
  45477. /**
  45478. * Class containing static functions to help procedurally build meshes
  45479. */
  45480. export class TorusBuilder {
  45481. /**
  45482. * Creates a torus mesh
  45483. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45484. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45485. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45487. * * 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
  45488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45489. * @param name defines the name of the mesh
  45490. * @param options defines the options used to create the mesh
  45491. * @param scene defines the hosting scene
  45492. * @returns the torus mesh
  45493. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45494. */
  45495. static CreateTorus(name: string, options: {
  45496. diameter?: number;
  45497. thickness?: number;
  45498. tessellation?: number;
  45499. updatable?: boolean;
  45500. sideOrientation?: number;
  45501. frontUVs?: Vector4;
  45502. backUVs?: Vector4;
  45503. }, scene: any): Mesh;
  45504. }
  45505. }
  45506. declare module BABYLON {
  45507. /**
  45508. * Class containing static functions to help procedurally build meshes
  45509. */
  45510. export class CylinderBuilder {
  45511. /**
  45512. * Creates a cylinder or a cone mesh
  45513. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45514. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45515. * * 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.
  45516. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45517. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45518. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45519. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45520. * * 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).
  45521. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45522. * * 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).
  45523. * * 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
  45524. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45525. * * 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
  45526. * * 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.
  45527. * * If `enclose` is false, a ring surface is one element.
  45528. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45529. * * 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
  45530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45531. * * 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
  45532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45533. * @param name defines the name of the mesh
  45534. * @param options defines the options used to create the mesh
  45535. * @param scene defines the hosting scene
  45536. * @returns the cylinder mesh
  45537. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45538. */
  45539. static CreateCylinder(name: string, options: {
  45540. height?: number;
  45541. diameterTop?: number;
  45542. diameterBottom?: number;
  45543. diameter?: number;
  45544. tessellation?: number;
  45545. subdivisions?: number;
  45546. arc?: number;
  45547. faceColors?: Color4[];
  45548. faceUV?: Vector4[];
  45549. updatable?: boolean;
  45550. hasRings?: boolean;
  45551. enclose?: boolean;
  45552. cap?: number;
  45553. sideOrientation?: number;
  45554. frontUVs?: Vector4;
  45555. backUVs?: Vector4;
  45556. }, scene: any): Mesh;
  45557. }
  45558. }
  45559. declare module BABYLON {
  45560. /**
  45561. * States of the webXR experience
  45562. */
  45563. export enum WebXRState {
  45564. /**
  45565. * Transitioning to being in XR mode
  45566. */
  45567. ENTERING_XR = 0,
  45568. /**
  45569. * Transitioning to non XR mode
  45570. */
  45571. EXITING_XR = 1,
  45572. /**
  45573. * In XR mode and presenting
  45574. */
  45575. IN_XR = 2,
  45576. /**
  45577. * Not entered XR mode
  45578. */
  45579. NOT_IN_XR = 3
  45580. }
  45581. /**
  45582. * Abstraction of the XR render target
  45583. */
  45584. export interface WebXRRenderTarget extends IDisposable {
  45585. /**
  45586. * xrpresent context of the canvas which can be used to display/mirror xr content
  45587. */
  45588. canvasContext: WebGLRenderingContext;
  45589. /**
  45590. * xr layer for the canvas
  45591. */
  45592. xrLayer: Nullable<XRWebGLLayer>;
  45593. /**
  45594. * Initializes the xr layer for the session
  45595. * @param xrSession xr session
  45596. * @returns a promise that will resolve once the XR Layer has been created
  45597. */
  45598. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45599. }
  45600. }
  45601. declare module BABYLON {
  45602. /**
  45603. * COnfiguration object for WebXR output canvas
  45604. */
  45605. export class WebXRManagedOutputCanvasOptions {
  45606. /**
  45607. * An optional canvas in case you wish to create it yourself and provide it here.
  45608. * If not provided, a new canvas will be created
  45609. */
  45610. canvasElement?: HTMLCanvasElement;
  45611. /**
  45612. * Options for this XR Layer output
  45613. */
  45614. canvasOptions?: XRWebGLLayerOptions;
  45615. /**
  45616. * CSS styling for a newly created canvas (if not provided)
  45617. */
  45618. newCanvasCssStyle?: string;
  45619. /**
  45620. * Get the default values of the configuration object
  45621. * @returns default values of this configuration object
  45622. */
  45623. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45624. }
  45625. /**
  45626. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45627. */
  45628. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45629. private _options;
  45630. private _canvas;
  45631. private _engine;
  45632. /**
  45633. * Rendering context of the canvas which can be used to display/mirror xr content
  45634. */
  45635. canvasContext: WebGLRenderingContext;
  45636. /**
  45637. * xr layer for the canvas
  45638. */
  45639. xrLayer: Nullable<XRWebGLLayer>;
  45640. /**
  45641. * Initializes the canvas to be added/removed upon entering/exiting xr
  45642. * @param _xrSessionManager The XR Session manager
  45643. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45644. */
  45645. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45646. /**
  45647. * Disposes of the object
  45648. */
  45649. dispose(): void;
  45650. /**
  45651. * Initializes the xr layer for the session
  45652. * @param xrSession xr session
  45653. * @returns a promise that will resolve once the XR Layer has been created
  45654. */
  45655. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45656. private _addCanvas;
  45657. private _removeCanvas;
  45658. private _setManagedOutputCanvas;
  45659. }
  45660. }
  45661. declare module BABYLON {
  45662. /**
  45663. * Manages an XRSession to work with Babylon's engine
  45664. * @see https://doc.babylonjs.com/how_to/webxr
  45665. */
  45666. export class WebXRSessionManager implements IDisposable {
  45667. /** The scene which the session should be created for */
  45668. scene: Scene;
  45669. private _referenceSpace;
  45670. private _rttProvider;
  45671. private _sessionEnded;
  45672. private _xrNavigator;
  45673. private baseLayer;
  45674. /**
  45675. * The base reference space from which the session started. good if you want to reset your
  45676. * reference space
  45677. */
  45678. baseReferenceSpace: XRReferenceSpace;
  45679. /**
  45680. * Current XR frame
  45681. */
  45682. currentFrame: Nullable<XRFrame>;
  45683. /** WebXR timestamp updated every frame */
  45684. currentTimestamp: number;
  45685. /**
  45686. * Used just in case of a failure to initialize an immersive session.
  45687. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45688. */
  45689. defaultHeightCompensation: number;
  45690. /**
  45691. * Fires every time a new xrFrame arrives which can be used to update the camera
  45692. */
  45693. onXRFrameObservable: Observable<XRFrame>;
  45694. /**
  45695. * Fires when the reference space changed
  45696. */
  45697. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45698. /**
  45699. * Fires when the xr session is ended either by the device or manually done
  45700. */
  45701. onXRSessionEnded: Observable<any>;
  45702. /**
  45703. * Fires when the xr session is ended either by the device or manually done
  45704. */
  45705. onXRSessionInit: Observable<XRSession>;
  45706. /**
  45707. * Underlying xr session
  45708. */
  45709. session: XRSession;
  45710. /**
  45711. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45712. * or get the offset the player is currently at.
  45713. */
  45714. viewerReferenceSpace: XRReferenceSpace;
  45715. /**
  45716. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45717. * @param scene The scene which the session should be created for
  45718. */
  45719. constructor(
  45720. /** The scene which the session should be created for */
  45721. scene: Scene);
  45722. /**
  45723. * The current reference space used in this session. This reference space can constantly change!
  45724. * It is mainly used to offset the camera's position.
  45725. */
  45726. get referenceSpace(): XRReferenceSpace;
  45727. /**
  45728. * Set a new reference space and triggers the observable
  45729. */
  45730. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45731. /**
  45732. * Disposes of the session manager
  45733. */
  45734. dispose(): void;
  45735. /**
  45736. * Stops the xrSession and restores the render loop
  45737. * @returns Promise which resolves after it exits XR
  45738. */
  45739. exitXRAsync(): Promise<void>;
  45740. /**
  45741. * Gets the correct render target texture to be rendered this frame for this eye
  45742. * @param eye the eye for which to get the render target
  45743. * @returns the render target for the specified eye
  45744. */
  45745. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  45746. /**
  45747. * Creates a WebXRRenderTarget object for the XR session
  45748. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  45749. * @param options optional options to provide when creating a new render target
  45750. * @returns a WebXR render target to which the session can render
  45751. */
  45752. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  45753. /**
  45754. * Initializes the manager
  45755. * After initialization enterXR can be called to start an XR session
  45756. * @returns Promise which resolves after it is initialized
  45757. */
  45758. initializeAsync(): Promise<void>;
  45759. /**
  45760. * Initializes an xr session
  45761. * @param xrSessionMode mode to initialize
  45762. * @param xrSessionInit defines optional and required values to pass to the session builder
  45763. * @returns a promise which will resolve once the session has been initialized
  45764. */
  45765. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  45766. /**
  45767. * Checks if a session would be supported for the creation options specified
  45768. * @param sessionMode session mode to check if supported eg. immersive-vr
  45769. * @returns A Promise that resolves to true if supported and false if not
  45770. */
  45771. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45772. /**
  45773. * Resets the reference space to the one started the session
  45774. */
  45775. resetReferenceSpace(): void;
  45776. /**
  45777. * Starts rendering to the xr layer
  45778. */
  45779. runXRRenderLoop(): void;
  45780. /**
  45781. * Sets the reference space on the xr session
  45782. * @param referenceSpaceType space to set
  45783. * @returns a promise that will resolve once the reference space has been set
  45784. */
  45785. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  45786. /**
  45787. * Updates the render state of the session
  45788. * @param state state to set
  45789. * @returns a promise that resolves once the render state has been updated
  45790. */
  45791. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  45792. /**
  45793. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  45794. * @param sessionMode defines the session to test
  45795. * @returns a promise with boolean as final value
  45796. */
  45797. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  45798. private _createRenderTargetTexture;
  45799. }
  45800. }
  45801. declare module BABYLON {
  45802. /**
  45803. * WebXR Camera which holds the views for the xrSession
  45804. * @see https://doc.babylonjs.com/how_to/webxr_camera
  45805. */
  45806. export class WebXRCamera extends FreeCamera {
  45807. private _xrSessionManager;
  45808. private _firstFrame;
  45809. private _referenceQuaternion;
  45810. private _referencedPosition;
  45811. private _xrInvPositionCache;
  45812. private _xrInvQuaternionCache;
  45813. /**
  45814. * Should position compensation execute on first frame.
  45815. * This is used when copying the position from a native (non XR) camera
  45816. */
  45817. compensateOnFirstFrame: boolean;
  45818. /**
  45819. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  45820. * @param name the name of the camera
  45821. * @param scene the scene to add the camera to
  45822. * @param _xrSessionManager a constructed xr session manager
  45823. */
  45824. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  45825. /**
  45826. * Return the user's height, unrelated to the current ground.
  45827. * This will be the y position of this camera, when ground level is 0.
  45828. */
  45829. get realWorldHeight(): number;
  45830. /** @hidden */
  45831. _updateForDualEyeDebugging(): void;
  45832. /**
  45833. * Sets this camera's transformation based on a non-vr camera
  45834. * @param otherCamera the non-vr camera to copy the transformation from
  45835. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  45836. */
  45837. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  45838. /**
  45839. * Gets the current instance class name ("WebXRCamera").
  45840. * @returns the class name
  45841. */
  45842. getClassName(): string;
  45843. /**
  45844. * Overriding the _getViewMatrix function, as it is computed by WebXR
  45845. */
  45846. _getViewMatrix(): Matrix;
  45847. private _updateFromXRSession;
  45848. private _updateNumberOfRigCameras;
  45849. private _updateReferenceSpace;
  45850. private _updateReferenceSpaceOffset;
  45851. }
  45852. }
  45853. declare module BABYLON {
  45854. /**
  45855. * Defining the interface required for a (webxr) feature
  45856. */
  45857. export interface IWebXRFeature extends IDisposable {
  45858. /**
  45859. * Is this feature attached
  45860. */
  45861. attached: boolean;
  45862. /**
  45863. * Should auto-attach be disabled?
  45864. */
  45865. disableAutoAttach: boolean;
  45866. /**
  45867. * Attach the feature to the session
  45868. * Will usually be called by the features manager
  45869. *
  45870. * @param force should attachment be forced (even when already attached)
  45871. * @returns true if successful.
  45872. */
  45873. attach(force?: boolean): boolean;
  45874. /**
  45875. * Detach the feature from the session
  45876. * Will usually be called by the features manager
  45877. *
  45878. * @returns true if successful.
  45879. */
  45880. detach(): boolean;
  45881. }
  45882. /**
  45883. * A list of the currently available features without referencing them
  45884. */
  45885. export class WebXRFeatureName {
  45886. /**
  45887. * The name of the anchor system feature
  45888. */
  45889. static ANCHOR_SYSTEM: string;
  45890. /**
  45891. * The name of the background remover feature
  45892. */
  45893. static BACKGROUND_REMOVER: string;
  45894. /**
  45895. * The name of the hit test feature
  45896. */
  45897. static HIT_TEST: string;
  45898. /**
  45899. * physics impostors for xr controllers feature
  45900. */
  45901. static PHYSICS_CONTROLLERS: string;
  45902. /**
  45903. * The name of the plane detection feature
  45904. */
  45905. static PLANE_DETECTION: string;
  45906. /**
  45907. * The name of the pointer selection feature
  45908. */
  45909. static POINTER_SELECTION: string;
  45910. /**
  45911. * The name of the teleportation feature
  45912. */
  45913. static TELEPORTATION: string;
  45914. }
  45915. /**
  45916. * Defining the constructor of a feature. Used to register the modules.
  45917. */
  45918. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  45919. /**
  45920. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  45921. * It is mainly used in AR sessions.
  45922. *
  45923. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  45924. */
  45925. export class WebXRFeaturesManager implements IDisposable {
  45926. private _xrSessionManager;
  45927. private static readonly _AvailableFeatures;
  45928. private _features;
  45929. /**
  45930. * constructs a new features manages.
  45931. *
  45932. * @param _xrSessionManager an instance of WebXRSessionManager
  45933. */
  45934. constructor(_xrSessionManager: WebXRSessionManager);
  45935. /**
  45936. * Used to register a module. After calling this function a developer can use this feature in the scene.
  45937. * Mainly used internally.
  45938. *
  45939. * @param featureName the name of the feature to register
  45940. * @param constructorFunction the function used to construct the module
  45941. * @param version the (babylon) version of the module
  45942. * @param stable is that a stable version of this module
  45943. */
  45944. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  45945. /**
  45946. * Returns a constructor of a specific feature.
  45947. *
  45948. * @param featureName the name of the feature to construct
  45949. * @param version the version of the feature to load
  45950. * @param xrSessionManager the xrSessionManager. Used to construct the module
  45951. * @param options optional options provided to the module.
  45952. * @returns a function that, when called, will return a new instance of this feature
  45953. */
  45954. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  45955. /**
  45956. * Can be used to return the list of features currently registered
  45957. *
  45958. * @returns an Array of available features
  45959. */
  45960. static GetAvailableFeatures(): string[];
  45961. /**
  45962. * Gets the versions available for a specific feature
  45963. * @param featureName the name of the feature
  45964. * @returns an array with the available versions
  45965. */
  45966. static GetAvailableVersions(featureName: string): string[];
  45967. /**
  45968. * Return the latest unstable version of this feature
  45969. * @param featureName the name of the feature to search
  45970. * @returns the version number. if not found will return -1
  45971. */
  45972. static GetLatestVersionOfFeature(featureName: string): number;
  45973. /**
  45974. * Return the latest stable version of this feature
  45975. * @param featureName the name of the feature to search
  45976. * @returns the version number. if not found will return -1
  45977. */
  45978. static GetStableVersionOfFeature(featureName: string): number;
  45979. /**
  45980. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  45981. * Can be used during a session to start a feature
  45982. * @param featureName the name of feature to attach
  45983. */
  45984. attachFeature(featureName: string): void;
  45985. /**
  45986. * Can be used inside a session or when the session ends to detach a specific feature
  45987. * @param featureName the name of the feature to detach
  45988. */
  45989. detachFeature(featureName: string): void;
  45990. /**
  45991. * Used to disable an already-enabled feature
  45992. * The feature will be disposed and will be recreated once enabled.
  45993. * @param featureName the feature to disable
  45994. * @returns true if disable was successful
  45995. */
  45996. disableFeature(featureName: string | {
  45997. Name: string;
  45998. }): boolean;
  45999. /**
  46000. * dispose this features manager
  46001. */
  46002. dispose(): void;
  46003. /**
  46004. * 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.
  46005. * 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.
  46006. *
  46007. * @param featureName the name of the feature to load or the class of the feature
  46008. * @param version optional version to load. if not provided the latest version will be enabled
  46009. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46010. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46011. * @returns a new constructed feature or throws an error if feature not found.
  46012. */
  46013. enableFeature(featureName: string | {
  46014. Name: string;
  46015. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46016. /**
  46017. * get the implementation of an enabled feature.
  46018. * @param featureName the name of the feature to load
  46019. * @returns the feature class, if found
  46020. */
  46021. getEnabledFeature(featureName: string): IWebXRFeature;
  46022. /**
  46023. * Get the list of enabled features
  46024. * @returns an array of enabled features
  46025. */
  46026. getEnabledFeatures(): string[];
  46027. }
  46028. }
  46029. declare module BABYLON {
  46030. /**
  46031. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46032. * @see https://doc.babylonjs.com/how_to/webxr
  46033. */
  46034. export class WebXRExperienceHelper implements IDisposable {
  46035. private scene;
  46036. private _nonVRCamera;
  46037. private _originalSceneAutoClear;
  46038. private _supported;
  46039. /**
  46040. * Camera used to render xr content
  46041. */
  46042. camera: WebXRCamera;
  46043. /** A features manager for this xr session */
  46044. featuresManager: WebXRFeaturesManager;
  46045. /**
  46046. * Observers registered here will be triggered after the camera's initial transformation is set
  46047. * This can be used to set a different ground level or an extra rotation.
  46048. *
  46049. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46050. * to the position set after this observable is done executing.
  46051. */
  46052. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46053. /**
  46054. * Fires when the state of the experience helper has changed
  46055. */
  46056. onStateChangedObservable: Observable<WebXRState>;
  46057. /** Session manager used to keep track of xr session */
  46058. sessionManager: WebXRSessionManager;
  46059. /**
  46060. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46061. */
  46062. state: WebXRState;
  46063. /**
  46064. * Creates a WebXRExperienceHelper
  46065. * @param scene The scene the helper should be created in
  46066. */
  46067. private constructor();
  46068. /**
  46069. * Creates the experience helper
  46070. * @param scene the scene to attach the experience helper to
  46071. * @returns a promise for the experience helper
  46072. */
  46073. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46074. /**
  46075. * Disposes of the experience helper
  46076. */
  46077. dispose(): void;
  46078. /**
  46079. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46080. * @param sessionMode options for the XR session
  46081. * @param referenceSpaceType frame of reference of the XR session
  46082. * @param renderTarget the output canvas that will be used to enter XR mode
  46083. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46084. * @returns promise that resolves after xr mode has entered
  46085. */
  46086. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46087. /**
  46088. * Exits XR mode and returns the scene to its original state
  46089. * @returns promise that resolves after xr mode has exited
  46090. */
  46091. exitXRAsync(): Promise<void>;
  46092. private _nonXRToXRCamera;
  46093. private _setState;
  46094. }
  46095. }
  46096. declare module BABYLON {
  46097. /**
  46098. * X-Y values for axes in WebXR
  46099. */
  46100. export interface IWebXRMotionControllerAxesValue {
  46101. /**
  46102. * The value of the x axis
  46103. */
  46104. x: number;
  46105. /**
  46106. * The value of the y-axis
  46107. */
  46108. y: number;
  46109. }
  46110. /**
  46111. * changed / previous values for the values of this component
  46112. */
  46113. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46114. /**
  46115. * current (this frame) value
  46116. */
  46117. current: T;
  46118. /**
  46119. * previous (last change) value
  46120. */
  46121. previous: T;
  46122. }
  46123. /**
  46124. * Represents changes in the component between current frame and last values recorded
  46125. */
  46126. export interface IWebXRMotionControllerComponentChanges {
  46127. /**
  46128. * will be populated with previous and current values if axes changed
  46129. */
  46130. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46131. /**
  46132. * will be populated with previous and current values if pressed changed
  46133. */
  46134. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46135. /**
  46136. * will be populated with previous and current values if touched changed
  46137. */
  46138. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46139. /**
  46140. * will be populated with previous and current values if value changed
  46141. */
  46142. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46143. }
  46144. /**
  46145. * This class represents a single component (for example button or thumbstick) of a motion controller
  46146. */
  46147. export class WebXRControllerComponent implements IDisposable {
  46148. /**
  46149. * the id of this component
  46150. */
  46151. id: string;
  46152. /**
  46153. * the type of the component
  46154. */
  46155. type: MotionControllerComponentType;
  46156. private _buttonIndex;
  46157. private _axesIndices;
  46158. private _axes;
  46159. private _changes;
  46160. private _currentValue;
  46161. private _hasChanges;
  46162. private _pressed;
  46163. private _touched;
  46164. /**
  46165. * button component type
  46166. */
  46167. static BUTTON_TYPE: MotionControllerComponentType;
  46168. /**
  46169. * squeeze component type
  46170. */
  46171. static SQUEEZE_TYPE: MotionControllerComponentType;
  46172. /**
  46173. * Thumbstick component type
  46174. */
  46175. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46176. /**
  46177. * Touchpad component type
  46178. */
  46179. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46180. /**
  46181. * trigger component type
  46182. */
  46183. static TRIGGER_TYPE: MotionControllerComponentType;
  46184. /**
  46185. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46186. * the axes data changes
  46187. */
  46188. onAxisValueChangedObservable: Observable<{
  46189. x: number;
  46190. y: number;
  46191. }>;
  46192. /**
  46193. * Observers registered here will be triggered when the state of a button changes
  46194. * State change is either pressed / touched / value
  46195. */
  46196. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46197. /**
  46198. * Creates a new component for a motion controller.
  46199. * It is created by the motion controller itself
  46200. *
  46201. * @param id the id of this component
  46202. * @param type the type of the component
  46203. * @param _buttonIndex index in the buttons array of the gamepad
  46204. * @param _axesIndices indices of the values in the axes array of the gamepad
  46205. */
  46206. constructor(
  46207. /**
  46208. * the id of this component
  46209. */
  46210. id: string,
  46211. /**
  46212. * the type of the component
  46213. */
  46214. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46215. /**
  46216. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46217. */
  46218. get axes(): IWebXRMotionControllerAxesValue;
  46219. /**
  46220. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46221. */
  46222. get changes(): IWebXRMotionControllerComponentChanges;
  46223. /**
  46224. * Return whether or not the component changed the last frame
  46225. */
  46226. get hasChanges(): boolean;
  46227. /**
  46228. * is the button currently pressed
  46229. */
  46230. get pressed(): boolean;
  46231. /**
  46232. * is the button currently touched
  46233. */
  46234. get touched(): boolean;
  46235. /**
  46236. * Get the current value of this component
  46237. */
  46238. get value(): number;
  46239. /**
  46240. * Dispose this component
  46241. */
  46242. dispose(): void;
  46243. /**
  46244. * Are there axes correlating to this component
  46245. * @return true is axes data is available
  46246. */
  46247. isAxes(): boolean;
  46248. /**
  46249. * Is this component a button (hence - pressable)
  46250. * @returns true if can be pressed
  46251. */
  46252. isButton(): boolean;
  46253. /**
  46254. * update this component using the gamepad object it is in. Called on every frame
  46255. * @param nativeController the native gamepad controller object
  46256. */
  46257. update(nativeController: IMinimalMotionControllerObject): void;
  46258. }
  46259. }
  46260. declare module BABYLON {
  46261. /**
  46262. * Class used to represent data loading progression
  46263. */
  46264. export class SceneLoaderProgressEvent {
  46265. /** defines if data length to load can be evaluated */
  46266. readonly lengthComputable: boolean;
  46267. /** defines the loaded data length */
  46268. readonly loaded: number;
  46269. /** defines the data length to load */
  46270. readonly total: number;
  46271. /**
  46272. * Create a new progress event
  46273. * @param lengthComputable defines if data length to load can be evaluated
  46274. * @param loaded defines the loaded data length
  46275. * @param total defines the data length to load
  46276. */
  46277. constructor(
  46278. /** defines if data length to load can be evaluated */
  46279. lengthComputable: boolean,
  46280. /** defines the loaded data length */
  46281. loaded: number,
  46282. /** defines the data length to load */
  46283. total: number);
  46284. /**
  46285. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46286. * @param event defines the source event
  46287. * @returns a new SceneLoaderProgressEvent
  46288. */
  46289. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46290. }
  46291. /**
  46292. * Interface used by SceneLoader plugins to define supported file extensions
  46293. */
  46294. export interface ISceneLoaderPluginExtensions {
  46295. /**
  46296. * Defines the list of supported extensions
  46297. */
  46298. [extension: string]: {
  46299. isBinary: boolean;
  46300. };
  46301. }
  46302. /**
  46303. * Interface used by SceneLoader plugin factory
  46304. */
  46305. export interface ISceneLoaderPluginFactory {
  46306. /**
  46307. * Defines the name of the factory
  46308. */
  46309. name: string;
  46310. /**
  46311. * Function called to create a new plugin
  46312. * @return the new plugin
  46313. */
  46314. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46315. /**
  46316. * The callback that returns true if the data can be directly loaded.
  46317. * @param data string containing the file data
  46318. * @returns if the data can be loaded directly
  46319. */
  46320. canDirectLoad?(data: string): boolean;
  46321. }
  46322. /**
  46323. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46324. */
  46325. export interface ISceneLoaderPluginBase {
  46326. /**
  46327. * The friendly name of this plugin.
  46328. */
  46329. name: string;
  46330. /**
  46331. * The file extensions supported by this plugin.
  46332. */
  46333. extensions: string | ISceneLoaderPluginExtensions;
  46334. /**
  46335. * The callback called when loading from a url.
  46336. * @param scene scene loading this url
  46337. * @param url url to load
  46338. * @param onSuccess callback called when the file successfully loads
  46339. * @param onProgress callback called while file is loading (if the server supports this mode)
  46340. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46341. * @param onError callback called when the file fails to load
  46342. * @returns a file request object
  46343. */
  46344. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46345. /**
  46346. * The callback called when loading from a file object.
  46347. * @param scene scene loading this file
  46348. * @param file defines the file to load
  46349. * @param onSuccess defines the callback to call when data is loaded
  46350. * @param onProgress defines the callback to call during loading process
  46351. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46352. * @param onError defines the callback to call when an error occurs
  46353. * @returns a file request object
  46354. */
  46355. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46356. /**
  46357. * The callback that returns true if the data can be directly loaded.
  46358. * @param data string containing the file data
  46359. * @returns if the data can be loaded directly
  46360. */
  46361. canDirectLoad?(data: string): boolean;
  46362. /**
  46363. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46364. * @param scene scene loading this data
  46365. * @param data string containing the data
  46366. * @returns data to pass to the plugin
  46367. */
  46368. directLoad?(scene: Scene, data: string): any;
  46369. /**
  46370. * The callback that allows custom handling of the root url based on the response url.
  46371. * @param rootUrl the original root url
  46372. * @param responseURL the response url if available
  46373. * @returns the new root url
  46374. */
  46375. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46376. }
  46377. /**
  46378. * Interface used to define a SceneLoader plugin
  46379. */
  46380. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46381. /**
  46382. * Import meshes into a scene.
  46383. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46384. * @param scene The scene to import into
  46385. * @param data The data to import
  46386. * @param rootUrl The root url for scene and resources
  46387. * @param meshes The meshes array to import into
  46388. * @param particleSystems The particle systems array to import into
  46389. * @param skeletons The skeletons array to import into
  46390. * @param onError The callback when import fails
  46391. * @returns True if successful or false otherwise
  46392. */
  46393. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46394. /**
  46395. * Load into a scene.
  46396. * @param scene The scene to load into
  46397. * @param data The data to import
  46398. * @param rootUrl The root url for scene and resources
  46399. * @param onError The callback when import fails
  46400. * @returns True if successful or false otherwise
  46401. */
  46402. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46403. /**
  46404. * Load into an asset container.
  46405. * @param scene The scene to load into
  46406. * @param data The data to import
  46407. * @param rootUrl The root url for scene and resources
  46408. * @param onError The callback when import fails
  46409. * @returns The loaded asset container
  46410. */
  46411. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46412. }
  46413. /**
  46414. * Interface used to define an async SceneLoader plugin
  46415. */
  46416. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46417. /**
  46418. * Import meshes into a scene.
  46419. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46420. * @param scene The scene to import into
  46421. * @param data The data to import
  46422. * @param rootUrl The root url for scene and resources
  46423. * @param onProgress The callback when the load progresses
  46424. * @param fileName Defines the name of the file to load
  46425. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46426. */
  46427. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46428. meshes: AbstractMesh[];
  46429. particleSystems: IParticleSystem[];
  46430. skeletons: Skeleton[];
  46431. animationGroups: AnimationGroup[];
  46432. }>;
  46433. /**
  46434. * Load into a scene.
  46435. * @param scene The scene to load into
  46436. * @param data The data to import
  46437. * @param rootUrl The root url for scene and resources
  46438. * @param onProgress The callback when the load progresses
  46439. * @param fileName Defines the name of the file to load
  46440. * @returns Nothing
  46441. */
  46442. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46443. /**
  46444. * Load into an asset container.
  46445. * @param scene The scene to load into
  46446. * @param data The data to import
  46447. * @param rootUrl The root url for scene and resources
  46448. * @param onProgress The callback when the load progresses
  46449. * @param fileName Defines the name of the file to load
  46450. * @returns The loaded asset container
  46451. */
  46452. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46453. }
  46454. /**
  46455. * Mode that determines how to handle old animation groups before loading new ones.
  46456. */
  46457. export enum SceneLoaderAnimationGroupLoadingMode {
  46458. /**
  46459. * Reset all old animations to initial state then dispose them.
  46460. */
  46461. Clean = 0,
  46462. /**
  46463. * Stop all old animations.
  46464. */
  46465. Stop = 1,
  46466. /**
  46467. * Restart old animations from first frame.
  46468. */
  46469. Sync = 2,
  46470. /**
  46471. * Old animations remains untouched.
  46472. */
  46473. NoSync = 3
  46474. }
  46475. /**
  46476. * Class used to load scene from various file formats using registered plugins
  46477. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46478. */
  46479. export class SceneLoader {
  46480. /**
  46481. * No logging while loading
  46482. */
  46483. static readonly NO_LOGGING: number;
  46484. /**
  46485. * Minimal logging while loading
  46486. */
  46487. static readonly MINIMAL_LOGGING: number;
  46488. /**
  46489. * Summary logging while loading
  46490. */
  46491. static readonly SUMMARY_LOGGING: number;
  46492. /**
  46493. * Detailled logging while loading
  46494. */
  46495. static readonly DETAILED_LOGGING: number;
  46496. /**
  46497. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46498. */
  46499. static get ForceFullSceneLoadingForIncremental(): boolean;
  46500. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46501. /**
  46502. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46503. */
  46504. static get ShowLoadingScreen(): boolean;
  46505. static set ShowLoadingScreen(value: boolean);
  46506. /**
  46507. * Defines the current logging level (while loading the scene)
  46508. * @ignorenaming
  46509. */
  46510. static get loggingLevel(): number;
  46511. static set loggingLevel(value: number);
  46512. /**
  46513. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46514. */
  46515. static get CleanBoneMatrixWeights(): boolean;
  46516. static set CleanBoneMatrixWeights(value: boolean);
  46517. /**
  46518. * Event raised when a plugin is used to load a scene
  46519. */
  46520. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46521. private static _registeredPlugins;
  46522. private static _getDefaultPlugin;
  46523. private static _getPluginForExtension;
  46524. private static _getPluginForDirectLoad;
  46525. private static _getPluginForFilename;
  46526. private static _getDirectLoad;
  46527. private static _loadData;
  46528. private static _getFileInfo;
  46529. /**
  46530. * Gets a plugin that can load the given extension
  46531. * @param extension defines the extension to load
  46532. * @returns a plugin or null if none works
  46533. */
  46534. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46535. /**
  46536. * Gets a boolean indicating that the given extension can be loaded
  46537. * @param extension defines the extension to load
  46538. * @returns true if the extension is supported
  46539. */
  46540. static IsPluginForExtensionAvailable(extension: string): boolean;
  46541. /**
  46542. * Adds a new plugin to the list of registered plugins
  46543. * @param plugin defines the plugin to add
  46544. */
  46545. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46546. /**
  46547. * Import meshes into a scene
  46548. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46549. * @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)
  46550. * @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)
  46551. * @param scene the instance of BABYLON.Scene to append to
  46552. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46553. * @param onProgress a callback with a progress event for each file being loaded
  46554. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46555. * @param pluginExtension the extension used to determine the plugin
  46556. * @returns The loaded plugin
  46557. */
  46558. 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>;
  46559. /**
  46560. * Import meshes into a scene
  46561. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46562. * @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)
  46563. * @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)
  46564. * @param scene the instance of BABYLON.Scene to append to
  46565. * @param onProgress a callback with a progress event for each file being loaded
  46566. * @param pluginExtension the extension used to determine the plugin
  46567. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46568. */
  46569. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46570. meshes: AbstractMesh[];
  46571. particleSystems: IParticleSystem[];
  46572. skeletons: Skeleton[];
  46573. animationGroups: AnimationGroup[];
  46574. }>;
  46575. /**
  46576. * Load a scene
  46577. * @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)
  46578. * @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)
  46579. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46580. * @param onSuccess a callback with the scene when import succeeds
  46581. * @param onProgress a callback with a progress event for each file being loaded
  46582. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46583. * @param pluginExtension the extension used to determine the plugin
  46584. * @returns The loaded plugin
  46585. */
  46586. 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>;
  46587. /**
  46588. * Load a scene
  46589. * @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)
  46590. * @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)
  46591. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46592. * @param onProgress a callback with a progress event for each file being loaded
  46593. * @param pluginExtension the extension used to determine the plugin
  46594. * @returns The loaded scene
  46595. */
  46596. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46597. /**
  46598. * Append a scene
  46599. * @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)
  46600. * @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)
  46601. * @param scene is the instance of BABYLON.Scene to append to
  46602. * @param onSuccess a callback with the scene when import succeeds
  46603. * @param onProgress a callback with a progress event for each file being loaded
  46604. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46605. * @param pluginExtension the extension used to determine the plugin
  46606. * @returns The loaded plugin
  46607. */
  46608. 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>;
  46609. /**
  46610. * Append a scene
  46611. * @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)
  46612. * @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)
  46613. * @param scene is the instance of BABYLON.Scene to append to
  46614. * @param onProgress a callback with a progress event for each file being loaded
  46615. * @param pluginExtension the extension used to determine the plugin
  46616. * @returns The given scene
  46617. */
  46618. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46619. /**
  46620. * Load a scene into an asset container
  46621. * @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)
  46622. * @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)
  46623. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46624. * @param onSuccess a callback with the scene when import succeeds
  46625. * @param onProgress a callback with a progress event for each file being loaded
  46626. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46627. * @param pluginExtension the extension used to determine the plugin
  46628. * @returns The loaded plugin
  46629. */
  46630. 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>;
  46631. /**
  46632. * Load a scene into an asset container
  46633. * @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)
  46634. * @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)
  46635. * @param scene is the instance of Scene to append to
  46636. * @param onProgress a callback with a progress event for each file being loaded
  46637. * @param pluginExtension the extension used to determine the plugin
  46638. * @returns The loaded asset container
  46639. */
  46640. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46641. /**
  46642. * Import animations from a file into a scene
  46643. * @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)
  46644. * @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)
  46645. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46646. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46647. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46648. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46649. * @param onSuccess a callback with the scene when import succeeds
  46650. * @param onProgress a callback with a progress event for each file being loaded
  46651. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46652. */
  46653. 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;
  46654. /**
  46655. * Import animations from a file into a scene
  46656. * @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)
  46657. * @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)
  46658. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46659. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46660. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46661. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46662. * @param onSuccess a callback with the scene when import succeeds
  46663. * @param onProgress a callback with a progress event for each file being loaded
  46664. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46665. * @returns the updated scene with imported animations
  46666. */
  46667. 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>;
  46668. }
  46669. }
  46670. declare module BABYLON {
  46671. /**
  46672. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46673. */
  46674. export type MotionControllerHandedness = "none" | "left" | "right";
  46675. /**
  46676. * The type of components available in motion controllers.
  46677. * This is not the name of the component.
  46678. */
  46679. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46680. /**
  46681. * The state of a controller component
  46682. */
  46683. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46684. /**
  46685. * The schema of motion controller layout.
  46686. * No object will be initialized using this interface
  46687. * This is used just to define the profile.
  46688. */
  46689. export interface IMotionControllerLayout {
  46690. /**
  46691. * Path to load the assets. Usually relative to the base path
  46692. */
  46693. assetPath: string;
  46694. /**
  46695. * Available components (unsorted)
  46696. */
  46697. components: {
  46698. /**
  46699. * A map of component Ids
  46700. */
  46701. [componentId: string]: {
  46702. /**
  46703. * The type of input the component outputs
  46704. */
  46705. type: MotionControllerComponentType;
  46706. /**
  46707. * The indices of this component in the gamepad object
  46708. */
  46709. gamepadIndices: {
  46710. /**
  46711. * Index of button
  46712. */
  46713. button?: number;
  46714. /**
  46715. * If available, index of x-axis
  46716. */
  46717. xAxis?: number;
  46718. /**
  46719. * If available, index of y-axis
  46720. */
  46721. yAxis?: number;
  46722. };
  46723. /**
  46724. * The mesh's root node name
  46725. */
  46726. rootNodeName: string;
  46727. /**
  46728. * Animation definitions for this model
  46729. */
  46730. visualResponses: {
  46731. [stateKey: string]: {
  46732. /**
  46733. * What property will be animated
  46734. */
  46735. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46736. /**
  46737. * What states influence this visual response
  46738. */
  46739. states: MotionControllerComponentStateType[];
  46740. /**
  46741. * Type of animation - movement or visibility
  46742. */
  46743. valueNodeProperty: "transform" | "visibility";
  46744. /**
  46745. * Base node name to move. Its position will be calculated according to the min and max nodes
  46746. */
  46747. valueNodeName?: string;
  46748. /**
  46749. * Minimum movement node
  46750. */
  46751. minNodeName?: string;
  46752. /**
  46753. * Max movement node
  46754. */
  46755. maxNodeName?: string;
  46756. };
  46757. };
  46758. /**
  46759. * If touch enabled, what is the name of node to display user feedback
  46760. */
  46761. touchPointNodeName?: string;
  46762. };
  46763. };
  46764. /**
  46765. * Is it xr standard mapping or not
  46766. */
  46767. gamepadMapping: "" | "xr-standard";
  46768. /**
  46769. * Base root node of this entire model
  46770. */
  46771. rootNodeName: string;
  46772. /**
  46773. * Defines the main button component id
  46774. */
  46775. selectComponentId: string;
  46776. }
  46777. /**
  46778. * A definition for the layout map in the input profile
  46779. */
  46780. export interface IMotionControllerLayoutMap {
  46781. /**
  46782. * Layouts with handedness type as a key
  46783. */
  46784. [handedness: string]: IMotionControllerLayout;
  46785. }
  46786. /**
  46787. * The XR Input profile schema
  46788. * Profiles can be found here:
  46789. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  46790. */
  46791. export interface IMotionControllerProfile {
  46792. /**
  46793. * fallback profiles for this profileId
  46794. */
  46795. fallbackProfileIds: string[];
  46796. /**
  46797. * The layout map, with handedness as key
  46798. */
  46799. layouts: IMotionControllerLayoutMap;
  46800. /**
  46801. * The id of this profile
  46802. * correlates to the profile(s) in the xrInput.profiles array
  46803. */
  46804. profileId: string;
  46805. }
  46806. /**
  46807. * A helper-interface for the 3 meshes needed for controller button animation
  46808. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  46809. */
  46810. export interface IMotionControllerButtonMeshMap {
  46811. /**
  46812. * the mesh that defines the pressed value mesh position.
  46813. * This is used to find the max-position of this button
  46814. */
  46815. pressedMesh: AbstractMesh;
  46816. /**
  46817. * the mesh that defines the unpressed value mesh position.
  46818. * This is used to find the min (or initial) position of this button
  46819. */
  46820. unpressedMesh: AbstractMesh;
  46821. /**
  46822. * The mesh that will be changed when value changes
  46823. */
  46824. valueMesh: AbstractMesh;
  46825. }
  46826. /**
  46827. * A helper-interface for the 3 meshes needed for controller axis animation.
  46828. * This will be expanded when touchpad animations are fully supported
  46829. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  46830. */
  46831. export interface IMotionControllerMeshMap {
  46832. /**
  46833. * the mesh that defines the maximum value mesh position.
  46834. */
  46835. maxMesh?: AbstractMesh;
  46836. /**
  46837. * the mesh that defines the minimum value mesh position.
  46838. */
  46839. minMesh?: AbstractMesh;
  46840. /**
  46841. * The mesh that will be changed when axis value changes
  46842. */
  46843. valueMesh: AbstractMesh;
  46844. }
  46845. /**
  46846. * The elements needed for change-detection of the gamepad objects in motion controllers
  46847. */
  46848. export interface IMinimalMotionControllerObject {
  46849. /**
  46850. * Available axes of this controller
  46851. */
  46852. axes: number[];
  46853. /**
  46854. * An array of available buttons
  46855. */
  46856. buttons: Array<{
  46857. /**
  46858. * Value of the button/trigger
  46859. */
  46860. value: number;
  46861. /**
  46862. * If the button/trigger is currently touched
  46863. */
  46864. touched: boolean;
  46865. /**
  46866. * If the button/trigger is currently pressed
  46867. */
  46868. pressed: boolean;
  46869. }>;
  46870. /**
  46871. * EXPERIMENTAL haptic support.
  46872. */
  46873. hapticActuators?: Array<{
  46874. pulse: (value: number, duration: number) => Promise<boolean>;
  46875. }>;
  46876. }
  46877. /**
  46878. * An Abstract Motion controller
  46879. * This class receives an xrInput and a profile layout and uses those to initialize the components
  46880. * Each component has an observable to check for changes in value and state
  46881. */
  46882. export abstract class WebXRAbstractMotionController implements IDisposable {
  46883. protected scene: Scene;
  46884. protected layout: IMotionControllerLayout;
  46885. /**
  46886. * The gamepad object correlating to this controller
  46887. */
  46888. gamepadObject: IMinimalMotionControllerObject;
  46889. /**
  46890. * handedness (left/right/none) of this controller
  46891. */
  46892. handedness: MotionControllerHandedness;
  46893. private _initComponent;
  46894. private _modelReady;
  46895. /**
  46896. * A map of components (WebXRControllerComponent) in this motion controller
  46897. * Components have a ComponentType and can also have both button and axis definitions
  46898. */
  46899. readonly components: {
  46900. [id: string]: WebXRControllerComponent;
  46901. };
  46902. /**
  46903. * Disable the model's animation. Can be set at any time.
  46904. */
  46905. disableAnimation: boolean;
  46906. /**
  46907. * Observers registered here will be triggered when the model of this controller is done loading
  46908. */
  46909. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  46910. /**
  46911. * The profile id of this motion controller
  46912. */
  46913. abstract profileId: string;
  46914. /**
  46915. * The root mesh of the model. It is null if the model was not yet initialized
  46916. */
  46917. rootMesh: Nullable<AbstractMesh>;
  46918. /**
  46919. * constructs a new abstract motion controller
  46920. * @param scene the scene to which the model of the controller will be added
  46921. * @param layout The profile layout to load
  46922. * @param gamepadObject The gamepad object correlating to this controller
  46923. * @param handedness handedness (left/right/none) of this controller
  46924. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  46925. */
  46926. constructor(scene: Scene, layout: IMotionControllerLayout,
  46927. /**
  46928. * The gamepad object correlating to this controller
  46929. */
  46930. gamepadObject: IMinimalMotionControllerObject,
  46931. /**
  46932. * handedness (left/right/none) of this controller
  46933. */
  46934. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  46935. /**
  46936. * Dispose this controller, the model mesh and all its components
  46937. */
  46938. dispose(): void;
  46939. /**
  46940. * Returns all components of specific type
  46941. * @param type the type to search for
  46942. * @return an array of components with this type
  46943. */
  46944. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  46945. /**
  46946. * get a component based an its component id as defined in layout.components
  46947. * @param id the id of the component
  46948. * @returns the component correlates to the id or undefined if not found
  46949. */
  46950. getComponent(id: string): WebXRControllerComponent;
  46951. /**
  46952. * Get the list of components available in this motion controller
  46953. * @returns an array of strings correlating to available components
  46954. */
  46955. getComponentIds(): string[];
  46956. /**
  46957. * Get the first component of specific type
  46958. * @param type type of component to find
  46959. * @return a controller component or null if not found
  46960. */
  46961. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  46962. /**
  46963. * Get the main (Select) component of this controller as defined in the layout
  46964. * @returns the main component of this controller
  46965. */
  46966. getMainComponent(): WebXRControllerComponent;
  46967. /**
  46968. * Loads the model correlating to this controller
  46969. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  46970. * @returns A promise fulfilled with the result of the model loading
  46971. */
  46972. loadModel(): Promise<boolean>;
  46973. /**
  46974. * Update this model using the current XRFrame
  46975. * @param xrFrame the current xr frame to use and update the model
  46976. */
  46977. updateFromXRFrame(xrFrame: XRFrame): void;
  46978. /**
  46979. * Backwards compatibility due to a deeply-integrated typo
  46980. */
  46981. get handness(): XREye;
  46982. /**
  46983. * Pulse (vibrate) this controller
  46984. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  46985. * Consecutive calls to this function will cancel the last pulse call
  46986. *
  46987. * @param value the strength of the pulse in 0.0...1.0 range
  46988. * @param duration Duration of the pulse in milliseconds
  46989. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  46990. * @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
  46991. */
  46992. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  46993. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46994. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  46995. /**
  46996. * Moves the axis on the controller mesh based on its current state
  46997. * @param axis the index of the axis
  46998. * @param axisValue the value of the axis which determines the meshes new position
  46999. * @hidden
  47000. */
  47001. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47002. /**
  47003. * Update the model itself with the current frame data
  47004. * @param xrFrame the frame to use for updating the model mesh
  47005. */
  47006. protected updateModel(xrFrame: XRFrame): void;
  47007. /**
  47008. * Get the filename and path for this controller's model
  47009. * @returns a map of filename and path
  47010. */
  47011. protected abstract _getFilenameAndPath(): {
  47012. filename: string;
  47013. path: string;
  47014. };
  47015. /**
  47016. * This function is called before the mesh is loaded. It checks for loading constraints.
  47017. * For example, this function can check if the GLB loader is available
  47018. * If this function returns false, the generic controller will be loaded instead
  47019. * @returns Is the client ready to load the mesh
  47020. */
  47021. protected abstract _getModelLoadingConstraints(): boolean;
  47022. /**
  47023. * This function will be called after the model was successfully loaded and can be used
  47024. * for mesh transformations before it is available for the user
  47025. * @param meshes the loaded meshes
  47026. */
  47027. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47028. /**
  47029. * Set the root mesh for this controller. Important for the WebXR controller class
  47030. * @param meshes the loaded meshes
  47031. */
  47032. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47033. /**
  47034. * A function executed each frame that updates the mesh (if needed)
  47035. * @param xrFrame the current xrFrame
  47036. */
  47037. protected abstract _updateModel(xrFrame: XRFrame): void;
  47038. private _getGenericFilenameAndPath;
  47039. private _getGenericParentMesh;
  47040. }
  47041. }
  47042. declare module BABYLON {
  47043. /**
  47044. * A generic trigger-only motion controller for WebXR
  47045. */
  47046. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47047. /**
  47048. * Static version of the profile id of this controller
  47049. */
  47050. static ProfileId: string;
  47051. profileId: string;
  47052. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47053. protected _getFilenameAndPath(): {
  47054. filename: string;
  47055. path: string;
  47056. };
  47057. protected _getModelLoadingConstraints(): boolean;
  47058. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47059. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47060. protected _updateModel(): void;
  47061. }
  47062. }
  47063. declare module BABYLON {
  47064. /**
  47065. * Class containing static functions to help procedurally build meshes
  47066. */
  47067. export class SphereBuilder {
  47068. /**
  47069. * Creates a sphere mesh
  47070. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47071. * * 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`)
  47072. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47073. * * 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
  47074. * * 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)
  47075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47076. * * 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
  47077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47078. * @param name defines the name of the mesh
  47079. * @param options defines the options used to create the mesh
  47080. * @param scene defines the hosting scene
  47081. * @returns the sphere mesh
  47082. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47083. */
  47084. static CreateSphere(name: string, options: {
  47085. segments?: number;
  47086. diameter?: number;
  47087. diameterX?: number;
  47088. diameterY?: number;
  47089. diameterZ?: number;
  47090. arc?: number;
  47091. slice?: number;
  47092. sideOrientation?: number;
  47093. frontUVs?: Vector4;
  47094. backUVs?: Vector4;
  47095. updatable?: boolean;
  47096. }, scene?: Nullable<Scene>): Mesh;
  47097. }
  47098. }
  47099. declare module BABYLON {
  47100. /**
  47101. * A profiled motion controller has its profile loaded from an online repository.
  47102. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47103. */
  47104. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47105. private _repositoryUrl;
  47106. private _buttonMeshMapping;
  47107. private _touchDots;
  47108. /**
  47109. * The profile ID of this controller. Will be populated when the controller initializes.
  47110. */
  47111. profileId: string;
  47112. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47113. dispose(): void;
  47114. protected _getFilenameAndPath(): {
  47115. filename: string;
  47116. path: string;
  47117. };
  47118. protected _getModelLoadingConstraints(): boolean;
  47119. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47120. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47121. protected _updateModel(_xrFrame: XRFrame): void;
  47122. }
  47123. }
  47124. declare module BABYLON {
  47125. /**
  47126. * A construction function type to create a new controller based on an xrInput object
  47127. */
  47128. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47129. /**
  47130. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47131. *
  47132. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47133. * it should be replaced with auto-loaded controllers.
  47134. *
  47135. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47136. */
  47137. export class WebXRMotionControllerManager {
  47138. private static _AvailableControllers;
  47139. private static _Fallbacks;
  47140. private static _ProfileLoadingPromises;
  47141. private static _ProfilesList;
  47142. /**
  47143. * The base URL of the online controller repository. Can be changed at any time.
  47144. */
  47145. static BaseRepositoryUrl: string;
  47146. /**
  47147. * Which repository gets priority - local or online
  47148. */
  47149. static PrioritizeOnlineRepository: boolean;
  47150. /**
  47151. * Use the online repository, or use only locally-defined controllers
  47152. */
  47153. static UseOnlineRepository: boolean;
  47154. /**
  47155. * Clear the cache used for profile loading and reload when requested again
  47156. */
  47157. static ClearProfilesCache(): void;
  47158. /**
  47159. * Register the default fallbacks.
  47160. * This function is called automatically when this file is imported.
  47161. */
  47162. static DefaultFallbacks(): void;
  47163. /**
  47164. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47165. * @param profileId the profile to which a fallback needs to be found
  47166. * @return an array with corresponding fallback profiles
  47167. */
  47168. static FindFallbackWithProfileId(profileId: string): string[];
  47169. /**
  47170. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47171. * The order of search:
  47172. *
  47173. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47174. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47175. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47176. * 4) return the generic trigger controller if none were found
  47177. *
  47178. * @param xrInput the xrInput to which a new controller is initialized
  47179. * @param scene the scene to which the model will be added
  47180. * @param forceProfile force a certain profile for this controller
  47181. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47182. */
  47183. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47184. /**
  47185. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47186. *
  47187. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47188. *
  47189. * @param type the profile type to register
  47190. * @param constructFunction the function to be called when loading this profile
  47191. */
  47192. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47193. /**
  47194. * Register a fallback to a specific profile.
  47195. * @param profileId the profileId that will receive the fallbacks
  47196. * @param fallbacks A list of fallback profiles
  47197. */
  47198. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47199. /**
  47200. * Will update the list of profiles available in the repository
  47201. * @return a promise that resolves to a map of profiles available online
  47202. */
  47203. static UpdateProfilesList(): Promise<{
  47204. [profile: string]: string;
  47205. }>;
  47206. private static _LoadProfileFromRepository;
  47207. private static _LoadProfilesFromAvailableControllers;
  47208. }
  47209. }
  47210. declare module BABYLON {
  47211. /**
  47212. * Configuration options for the WebXR controller creation
  47213. */
  47214. export interface IWebXRControllerOptions {
  47215. /**
  47216. * Should the controller mesh be animated when a user interacts with it
  47217. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47218. */
  47219. disableMotionControllerAnimation?: boolean;
  47220. /**
  47221. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47222. */
  47223. doNotLoadControllerMesh?: boolean;
  47224. /**
  47225. * Force a specific controller type for this controller.
  47226. * This can be used when creating your own profile or when testing different controllers
  47227. */
  47228. forceControllerProfile?: string;
  47229. /**
  47230. * Defines a rendering group ID for meshes that will be loaded.
  47231. * This is for the default controllers only.
  47232. */
  47233. renderingGroupId?: number;
  47234. }
  47235. /**
  47236. * Represents an XR controller
  47237. */
  47238. export class WebXRInputSource {
  47239. private _scene;
  47240. /** The underlying input source for the controller */
  47241. inputSource: XRInputSource;
  47242. private _options;
  47243. private _tmpVector;
  47244. private _uniqueId;
  47245. /**
  47246. * 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
  47247. */
  47248. grip?: AbstractMesh;
  47249. /**
  47250. * If available, this is the gamepad object related to this controller.
  47251. * Using this object it is possible to get click events and trackpad changes of the
  47252. * webxr controller that is currently being used.
  47253. */
  47254. motionController?: WebXRAbstractMotionController;
  47255. /**
  47256. * Event that fires when the controller is removed/disposed.
  47257. * The object provided as event data is this controller, after associated assets were disposed.
  47258. * uniqueId is still available.
  47259. */
  47260. onDisposeObservable: Observable<WebXRInputSource>;
  47261. /**
  47262. * Will be triggered when the mesh associated with the motion controller is done loading.
  47263. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47264. * A shortened version of controller -> motion controller -> on mesh loaded.
  47265. */
  47266. onMeshLoadedObservable: Observable<AbstractMesh>;
  47267. /**
  47268. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47269. */
  47270. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47271. /**
  47272. * Pointer which can be used to select objects or attach a visible laser to
  47273. */
  47274. pointer: AbstractMesh;
  47275. /**
  47276. * Creates the controller
  47277. * @see https://doc.babylonjs.com/how_to/webxr
  47278. * @param _scene the scene which the controller should be associated to
  47279. * @param inputSource the underlying input source for the controller
  47280. * @param _options options for this controller creation
  47281. */
  47282. constructor(_scene: Scene,
  47283. /** The underlying input source for the controller */
  47284. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47285. /**
  47286. * Get this controllers unique id
  47287. */
  47288. get uniqueId(): string;
  47289. /**
  47290. * Disposes of the object
  47291. */
  47292. dispose(): void;
  47293. /**
  47294. * Gets a world space ray coming from the pointer or grip
  47295. * @param result the resulting ray
  47296. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47297. */
  47298. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47299. /**
  47300. * Updates the controller pose based on the given XRFrame
  47301. * @param xrFrame xr frame to update the pose with
  47302. * @param referenceSpace reference space to use
  47303. */
  47304. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47305. }
  47306. }
  47307. declare module BABYLON {
  47308. /**
  47309. * The schema for initialization options of the XR Input class
  47310. */
  47311. export interface IWebXRInputOptions {
  47312. /**
  47313. * If set to true no model will be automatically loaded
  47314. */
  47315. doNotLoadControllerMeshes?: boolean;
  47316. /**
  47317. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47318. * If not found, the xr input profile data will be used.
  47319. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47320. */
  47321. forceInputProfile?: string;
  47322. /**
  47323. * Do not send a request to the controller repository to load the profile.
  47324. *
  47325. * Instead, use the controllers available in babylon itself.
  47326. */
  47327. disableOnlineControllerRepository?: boolean;
  47328. /**
  47329. * A custom URL for the controllers repository
  47330. */
  47331. customControllersRepositoryURL?: string;
  47332. /**
  47333. * Should the controller model's components not move according to the user input
  47334. */
  47335. disableControllerAnimation?: boolean;
  47336. /**
  47337. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47338. */
  47339. controllerOptions?: IWebXRControllerOptions;
  47340. }
  47341. /**
  47342. * XR input used to track XR inputs such as controllers/rays
  47343. */
  47344. export class WebXRInput implements IDisposable {
  47345. /**
  47346. * the xr session manager for this session
  47347. */
  47348. xrSessionManager: WebXRSessionManager;
  47349. /**
  47350. * the WebXR camera for this session. Mainly used for teleportation
  47351. */
  47352. xrCamera: WebXRCamera;
  47353. private readonly options;
  47354. /**
  47355. * XR controllers being tracked
  47356. */
  47357. controllers: Array<WebXRInputSource>;
  47358. private _frameObserver;
  47359. private _sessionEndedObserver;
  47360. private _sessionInitObserver;
  47361. /**
  47362. * Event when a controller has been connected/added
  47363. */
  47364. onControllerAddedObservable: Observable<WebXRInputSource>;
  47365. /**
  47366. * Event when a controller has been removed/disconnected
  47367. */
  47368. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47369. /**
  47370. * Initializes the WebXRInput
  47371. * @param xrSessionManager the xr session manager for this session
  47372. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47373. * @param options = initialization options for this xr input
  47374. */
  47375. constructor(
  47376. /**
  47377. * the xr session manager for this session
  47378. */
  47379. xrSessionManager: WebXRSessionManager,
  47380. /**
  47381. * the WebXR camera for this session. Mainly used for teleportation
  47382. */
  47383. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47384. private _onInputSourcesChange;
  47385. private _addAndRemoveControllers;
  47386. /**
  47387. * Disposes of the object
  47388. */
  47389. dispose(): void;
  47390. }
  47391. }
  47392. declare module BABYLON {
  47393. /**
  47394. * This is the base class for all WebXR features.
  47395. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47396. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47397. */
  47398. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47399. protected _xrSessionManager: WebXRSessionManager;
  47400. private _attached;
  47401. private _removeOnDetach;
  47402. /**
  47403. * Should auto-attach be disabled?
  47404. */
  47405. disableAutoAttach: boolean;
  47406. /**
  47407. * Construct a new (abstract) WebXR feature
  47408. * @param _xrSessionManager the xr session manager for this feature
  47409. */
  47410. constructor(_xrSessionManager: WebXRSessionManager);
  47411. /**
  47412. * Is this feature attached
  47413. */
  47414. get attached(): boolean;
  47415. /**
  47416. * attach this feature
  47417. *
  47418. * @param force should attachment be forced (even when already attached)
  47419. * @returns true if successful, false is failed or already attached
  47420. */
  47421. attach(force?: boolean): boolean;
  47422. /**
  47423. * detach this feature.
  47424. *
  47425. * @returns true if successful, false if failed or already detached
  47426. */
  47427. detach(): boolean;
  47428. /**
  47429. * Dispose this feature and all of the resources attached
  47430. */
  47431. dispose(): void;
  47432. /**
  47433. * This is used to register callbacks that will automatically be removed when detach is called.
  47434. * @param observable the observable to which the observer will be attached
  47435. * @param callback the callback to register
  47436. */
  47437. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47438. /**
  47439. * Code in this function will be executed on each xrFrame received from the browser.
  47440. * This function will not execute after the feature is detached.
  47441. * @param _xrFrame the current frame
  47442. */
  47443. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47444. }
  47445. }
  47446. declare module BABYLON {
  47447. /**
  47448. * Renders a layer on top of an existing scene
  47449. */
  47450. export class UtilityLayerRenderer implements IDisposable {
  47451. /** the original scene that will be rendered on top of */
  47452. originalScene: Scene;
  47453. private _pointerCaptures;
  47454. private _lastPointerEvents;
  47455. private static _DefaultUtilityLayer;
  47456. private static _DefaultKeepDepthUtilityLayer;
  47457. private _sharedGizmoLight;
  47458. private _renderCamera;
  47459. /**
  47460. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47461. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47462. * @returns the camera that is used when rendering the utility layer
  47463. */
  47464. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47465. /**
  47466. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47467. * @param cam the camera that should be used when rendering the utility layer
  47468. */
  47469. setRenderCamera(cam: Nullable<Camera>): void;
  47470. /**
  47471. * @hidden
  47472. * Light which used by gizmos to get light shading
  47473. */
  47474. _getSharedGizmoLight(): HemisphericLight;
  47475. /**
  47476. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47477. */
  47478. pickUtilitySceneFirst: boolean;
  47479. /**
  47480. * 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)
  47481. */
  47482. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47483. /**
  47484. * 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)
  47485. */
  47486. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47487. /**
  47488. * The scene that is rendered on top of the original scene
  47489. */
  47490. utilityLayerScene: Scene;
  47491. /**
  47492. * If the utility layer should automatically be rendered on top of existing scene
  47493. */
  47494. shouldRender: boolean;
  47495. /**
  47496. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47497. */
  47498. onlyCheckPointerDownEvents: boolean;
  47499. /**
  47500. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47501. */
  47502. processAllEvents: boolean;
  47503. /**
  47504. * Observable raised when the pointer move from the utility layer scene to the main scene
  47505. */
  47506. onPointerOutObservable: Observable<number>;
  47507. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47508. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47509. private _afterRenderObserver;
  47510. private _sceneDisposeObserver;
  47511. private _originalPointerObserver;
  47512. /**
  47513. * Instantiates a UtilityLayerRenderer
  47514. * @param originalScene the original scene that will be rendered on top of
  47515. * @param handleEvents boolean indicating if the utility layer should handle events
  47516. */
  47517. constructor(
  47518. /** the original scene that will be rendered on top of */
  47519. originalScene: Scene, handleEvents?: boolean);
  47520. private _notifyObservers;
  47521. /**
  47522. * Renders the utility layers scene on top of the original scene
  47523. */
  47524. render(): void;
  47525. /**
  47526. * Disposes of the renderer
  47527. */
  47528. dispose(): void;
  47529. private _updateCamera;
  47530. }
  47531. }
  47532. declare module BABYLON {
  47533. /**
  47534. * Options interface for the pointer selection module
  47535. */
  47536. export interface IWebXRControllerPointerSelectionOptions {
  47537. /**
  47538. * if provided, this scene will be used to render meshes.
  47539. */
  47540. customUtilityLayerScene?: Scene;
  47541. /**
  47542. * 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)
  47543. * If not disabled, the last picked point will be used to execute a pointer up event
  47544. * If disabled, pointer up event will be triggered right after the pointer down event.
  47545. * Used in screen and gaze target ray mode only
  47546. */
  47547. disablePointerUpOnTouchOut: boolean;
  47548. /**
  47549. * For gaze mode (time to select instead of press)
  47550. */
  47551. forceGazeMode: boolean;
  47552. /**
  47553. * 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
  47554. * to start a new countdown to the pointer down event.
  47555. * Defaults to 1.
  47556. */
  47557. gazeModePointerMovedFactor?: number;
  47558. /**
  47559. * Different button type to use instead of the main component
  47560. */
  47561. overrideButtonId?: string;
  47562. /**
  47563. * use this rendering group id for the meshes (optional)
  47564. */
  47565. renderingGroupId?: number;
  47566. /**
  47567. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47568. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47569. * 3000 means 3 seconds between pointing at something and selecting it
  47570. */
  47571. timeToSelect?: number;
  47572. /**
  47573. * Should meshes created here be added to a utility layer or the main scene
  47574. */
  47575. useUtilityLayer?: boolean;
  47576. /**
  47577. * the xr input to use with this pointer selection
  47578. */
  47579. xrInput: WebXRInput;
  47580. }
  47581. /**
  47582. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47583. */
  47584. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47585. private readonly _options;
  47586. private static _idCounter;
  47587. private _attachController;
  47588. private _controllers;
  47589. private _scene;
  47590. private _tmpVectorForPickCompare;
  47591. /**
  47592. * The module's name
  47593. */
  47594. static readonly Name: string;
  47595. /**
  47596. * The (Babylon) version of this module.
  47597. * This is an integer representing the implementation version.
  47598. * This number does not correspond to the WebXR specs version
  47599. */
  47600. static readonly Version: number;
  47601. /**
  47602. * Disable lighting on the laser pointer (so it will always be visible)
  47603. */
  47604. disablePointerLighting: boolean;
  47605. /**
  47606. * Disable lighting on the selection mesh (so it will always be visible)
  47607. */
  47608. disableSelectionMeshLighting: boolean;
  47609. /**
  47610. * Should the laser pointer be displayed
  47611. */
  47612. displayLaserPointer: boolean;
  47613. /**
  47614. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47615. */
  47616. displaySelectionMesh: boolean;
  47617. /**
  47618. * This color will be set to the laser pointer when selection is triggered
  47619. */
  47620. laserPointerPickedColor: Color3;
  47621. /**
  47622. * Default color of the laser pointer
  47623. */
  47624. lasterPointerDefaultColor: Color3;
  47625. /**
  47626. * default color of the selection ring
  47627. */
  47628. selectionMeshDefaultColor: Color3;
  47629. /**
  47630. * This color will be applied to the selection ring when selection is triggered
  47631. */
  47632. selectionMeshPickedColor: Color3;
  47633. /**
  47634. * Optional filter to be used for ray selection. This predicate shares behavior with
  47635. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47636. */
  47637. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47638. /**
  47639. * constructs a new background remover module
  47640. * @param _xrSessionManager the session manager for this module
  47641. * @param _options read-only options to be used in this module
  47642. */
  47643. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47644. /**
  47645. * attach this feature
  47646. * Will usually be called by the features manager
  47647. *
  47648. * @returns true if successful.
  47649. */
  47650. attach(): boolean;
  47651. /**
  47652. * detach this feature.
  47653. * Will usually be called by the features manager
  47654. *
  47655. * @returns true if successful.
  47656. */
  47657. detach(): boolean;
  47658. /**
  47659. * Will get the mesh under a specific pointer.
  47660. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47661. * @param controllerId the controllerId to check
  47662. * @returns The mesh under pointer or null if no mesh is under the pointer
  47663. */
  47664. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47665. /**
  47666. * Get the xr controller that correlates to the pointer id in the pointer event
  47667. *
  47668. * @param id the pointer id to search for
  47669. * @returns the controller that correlates to this id or null if not found
  47670. */
  47671. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47672. protected _onXRFrame(_xrFrame: XRFrame): void;
  47673. private _attachGazeMode;
  47674. private _attachScreenRayMode;
  47675. private _attachTrackedPointerRayMode;
  47676. private _convertNormalToDirectionOfRay;
  47677. private _detachController;
  47678. private _generateNewMeshPair;
  47679. private _pickingMoved;
  47680. private _updatePointerDistance;
  47681. }
  47682. }
  47683. declare module BABYLON {
  47684. /**
  47685. * Button which can be used to enter a different mode of XR
  47686. */
  47687. export class WebXREnterExitUIButton {
  47688. /** button element */
  47689. element: HTMLElement;
  47690. /** XR initialization options for the button */
  47691. sessionMode: XRSessionMode;
  47692. /** Reference space type */
  47693. referenceSpaceType: XRReferenceSpaceType;
  47694. /**
  47695. * Creates a WebXREnterExitUIButton
  47696. * @param element button element
  47697. * @param sessionMode XR initialization session mode
  47698. * @param referenceSpaceType the type of reference space to be used
  47699. */
  47700. constructor(
  47701. /** button element */
  47702. element: HTMLElement,
  47703. /** XR initialization options for the button */
  47704. sessionMode: XRSessionMode,
  47705. /** Reference space type */
  47706. referenceSpaceType: XRReferenceSpaceType);
  47707. /**
  47708. * Extendable function which can be used to update the button's visuals when the state changes
  47709. * @param activeButton the current active button in the UI
  47710. */
  47711. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47712. }
  47713. /**
  47714. * Options to create the webXR UI
  47715. */
  47716. export class WebXREnterExitUIOptions {
  47717. /**
  47718. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47719. */
  47720. customButtons?: Array<WebXREnterExitUIButton>;
  47721. /**
  47722. * A reference space type to use when creating the default button.
  47723. * Default is local-floor
  47724. */
  47725. referenceSpaceType?: XRReferenceSpaceType;
  47726. /**
  47727. * Context to enter xr with
  47728. */
  47729. renderTarget?: Nullable<WebXRRenderTarget>;
  47730. /**
  47731. * A session mode to use when creating the default button.
  47732. * Default is immersive-vr
  47733. */
  47734. sessionMode?: XRSessionMode;
  47735. /**
  47736. * A list of optional features to init the session with
  47737. */
  47738. optionalFeatures?: string[];
  47739. }
  47740. /**
  47741. * UI to allow the user to enter/exit XR mode
  47742. */
  47743. export class WebXREnterExitUI implements IDisposable {
  47744. private scene;
  47745. /** version of the options passed to this UI */
  47746. options: WebXREnterExitUIOptions;
  47747. private _activeButton;
  47748. private _buttons;
  47749. private _overlay;
  47750. /**
  47751. * Fired every time the active button is changed.
  47752. *
  47753. * When xr is entered via a button that launches xr that button will be the callback parameter
  47754. *
  47755. * When exiting xr the callback parameter will be null)
  47756. */
  47757. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  47758. /**
  47759. *
  47760. * @param scene babylon scene object to use
  47761. * @param options (read-only) version of the options passed to this UI
  47762. */
  47763. private constructor();
  47764. /**
  47765. * Creates UI to allow the user to enter/exit XR mode
  47766. * @param scene the scene to add the ui to
  47767. * @param helper the xr experience helper to enter/exit xr with
  47768. * @param options options to configure the UI
  47769. * @returns the created ui
  47770. */
  47771. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  47772. /**
  47773. * Disposes of the XR UI component
  47774. */
  47775. dispose(): void;
  47776. private _updateButtons;
  47777. }
  47778. }
  47779. declare module BABYLON {
  47780. /**
  47781. * Class containing static functions to help procedurally build meshes
  47782. */
  47783. export class LinesBuilder {
  47784. /**
  47785. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47786. * * 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
  47787. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47788. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47789. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47790. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47791. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47792. * * 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
  47793. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47795. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47796. * @param name defines the name of the new line system
  47797. * @param options defines the options used to create the line system
  47798. * @param scene defines the hosting scene
  47799. * @returns a new line system mesh
  47800. */
  47801. static CreateLineSystem(name: string, options: {
  47802. lines: Vector3[][];
  47803. updatable?: boolean;
  47804. instance?: Nullable<LinesMesh>;
  47805. colors?: Nullable<Color4[][]>;
  47806. useVertexAlpha?: boolean;
  47807. }, scene: Nullable<Scene>): LinesMesh;
  47808. /**
  47809. * Creates a line mesh
  47810. * 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
  47811. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47812. * * The parameter `points` is an array successive Vector3
  47813. * * 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
  47814. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47815. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47816. * * When updating an instance, remember that only point positions can change, not the number of points
  47817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47818. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47819. * @param name defines the name of the new line system
  47820. * @param options defines the options used to create the line system
  47821. * @param scene defines the hosting scene
  47822. * @returns a new line mesh
  47823. */
  47824. static CreateLines(name: string, options: {
  47825. points: Vector3[];
  47826. updatable?: boolean;
  47827. instance?: Nullable<LinesMesh>;
  47828. colors?: Color4[];
  47829. useVertexAlpha?: boolean;
  47830. }, scene?: Nullable<Scene>): LinesMesh;
  47831. /**
  47832. * Creates a dashed line mesh
  47833. * * 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
  47834. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47835. * * The parameter `points` is an array successive Vector3
  47836. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47837. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47838. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47839. * * 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
  47840. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47841. * * When updating an instance, remember that only point positions can change, not the number of points
  47842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47843. * @param name defines the name of the mesh
  47844. * @param options defines the options used to create the mesh
  47845. * @param scene defines the hosting scene
  47846. * @returns the dashed line mesh
  47847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47848. */
  47849. static CreateDashedLines(name: string, options: {
  47850. points: Vector3[];
  47851. dashSize?: number;
  47852. gapSize?: number;
  47853. dashNb?: number;
  47854. updatable?: boolean;
  47855. instance?: LinesMesh;
  47856. useVertexAlpha?: boolean;
  47857. }, scene?: Nullable<Scene>): LinesMesh;
  47858. }
  47859. }
  47860. declare module BABYLON {
  47861. /**
  47862. * The options container for the teleportation module
  47863. */
  47864. export interface IWebXRTeleportationOptions {
  47865. /**
  47866. * if provided, this scene will be used to render meshes.
  47867. */
  47868. customUtilityLayerScene?: Scene;
  47869. /**
  47870. * Values to configure the default target mesh
  47871. */
  47872. defaultTargetMeshOptions?: {
  47873. /**
  47874. * Fill color of the teleportation area
  47875. */
  47876. teleportationFillColor?: string;
  47877. /**
  47878. * Border color for the teleportation area
  47879. */
  47880. teleportationBorderColor?: string;
  47881. /**
  47882. * Disable the mesh's animation sequence
  47883. */
  47884. disableAnimation?: boolean;
  47885. /**
  47886. * Disable lighting on the material or the ring and arrow
  47887. */
  47888. disableLighting?: boolean;
  47889. /**
  47890. * Override the default material of the torus and arrow
  47891. */
  47892. torusArrowMaterial?: Material;
  47893. };
  47894. /**
  47895. * A list of meshes to use as floor meshes.
  47896. * Meshes can be added and removed after initializing the feature using the
  47897. * addFloorMesh and removeFloorMesh functions
  47898. * If empty, rotation will still work
  47899. */
  47900. floorMeshes?: AbstractMesh[];
  47901. /**
  47902. * use this rendering group id for the meshes (optional)
  47903. */
  47904. renderingGroupId?: number;
  47905. /**
  47906. * Should teleportation move only to snap points
  47907. */
  47908. snapPointsOnly?: boolean;
  47909. /**
  47910. * An array of points to which the teleportation will snap to.
  47911. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  47912. */
  47913. snapPositions?: Vector3[];
  47914. /**
  47915. * How close should the teleportation ray be in order to snap to position.
  47916. * Default to 0.8 units (meters)
  47917. */
  47918. snapToPositionRadius?: number;
  47919. /**
  47920. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  47921. * If you want to support rotation, make sure your mesh has a direction indicator.
  47922. *
  47923. * When left untouched, the default mesh will be initialized.
  47924. */
  47925. teleportationTargetMesh?: AbstractMesh;
  47926. /**
  47927. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  47928. */
  47929. timeToTeleport?: number;
  47930. /**
  47931. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  47932. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  47933. */
  47934. useMainComponentOnly?: boolean;
  47935. /**
  47936. * Should meshes created here be added to a utility layer or the main scene
  47937. */
  47938. useUtilityLayer?: boolean;
  47939. /**
  47940. * Babylon XR Input class for controller
  47941. */
  47942. xrInput: WebXRInput;
  47943. }
  47944. /**
  47945. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  47946. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  47947. * the input of the attached controllers.
  47948. */
  47949. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  47950. private _options;
  47951. private _controllers;
  47952. private _currentTeleportationControllerId;
  47953. private _floorMeshes;
  47954. private _quadraticBezierCurve;
  47955. private _selectionFeature;
  47956. private _snapToPositions;
  47957. private _snappedToPoint;
  47958. private _teleportationRingMaterial?;
  47959. private _tmpRay;
  47960. private _tmpVector;
  47961. /**
  47962. * The module's name
  47963. */
  47964. static readonly Name: string;
  47965. /**
  47966. * The (Babylon) version of this module.
  47967. * This is an integer representing the implementation version.
  47968. * This number does not correspond to the webxr specs version
  47969. */
  47970. static readonly Version: number;
  47971. /**
  47972. * Is movement backwards enabled
  47973. */
  47974. backwardsMovementEnabled: boolean;
  47975. /**
  47976. * Distance to travel when moving backwards
  47977. */
  47978. backwardsTeleportationDistance: number;
  47979. /**
  47980. * The distance from the user to the inspection point in the direction of the controller
  47981. * A higher number will allow the user to move further
  47982. * defaults to 5 (meters, in xr units)
  47983. */
  47984. parabolicCheckRadius: number;
  47985. /**
  47986. * Should the module support parabolic ray on top of direct ray
  47987. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  47988. * Very helpful when moving between floors / different heights
  47989. */
  47990. parabolicRayEnabled: boolean;
  47991. /**
  47992. * How much rotation should be applied when rotating right and left
  47993. */
  47994. rotationAngle: number;
  47995. /**
  47996. * Is rotation enabled when moving forward?
  47997. * Disabling this feature will prevent the user from deciding the direction when teleporting
  47998. */
  47999. rotationEnabled: boolean;
  48000. /**
  48001. * constructs a new anchor system
  48002. * @param _xrSessionManager an instance of WebXRSessionManager
  48003. * @param _options configuration object for this feature
  48004. */
  48005. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48006. /**
  48007. * Get the snapPointsOnly flag
  48008. */
  48009. get snapPointsOnly(): boolean;
  48010. /**
  48011. * Sets the snapPointsOnly flag
  48012. * @param snapToPoints should teleportation be exclusively to snap points
  48013. */
  48014. set snapPointsOnly(snapToPoints: boolean);
  48015. /**
  48016. * Add a new mesh to the floor meshes array
  48017. * @param mesh the mesh to use as floor mesh
  48018. */
  48019. addFloorMesh(mesh: AbstractMesh): void;
  48020. /**
  48021. * Add a new snap-to point to fix teleportation to this position
  48022. * @param newSnapPoint The new Snap-To point
  48023. */
  48024. addSnapPoint(newSnapPoint: Vector3): void;
  48025. attach(): boolean;
  48026. detach(): boolean;
  48027. dispose(): void;
  48028. /**
  48029. * Remove a mesh from the floor meshes array
  48030. * @param mesh the mesh to remove
  48031. */
  48032. removeFloorMesh(mesh: AbstractMesh): void;
  48033. /**
  48034. * Remove a mesh from the floor meshes array using its name
  48035. * @param name the mesh name to remove
  48036. */
  48037. removeFloorMeshByName(name: string): void;
  48038. /**
  48039. * 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
  48040. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48041. * @returns was the point found and removed or not
  48042. */
  48043. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48044. /**
  48045. * This function sets a selection feature that will be disabled when
  48046. * the forward ray is shown and will be reattached when hidden.
  48047. * This is used to remove the selection rays when moving.
  48048. * @param selectionFeature the feature to disable when forward movement is enabled
  48049. */
  48050. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48051. protected _onXRFrame(_xrFrame: XRFrame): void;
  48052. private _attachController;
  48053. private _createDefaultTargetMesh;
  48054. private _detachController;
  48055. private _findClosestSnapPointWithRadius;
  48056. private _setTargetMeshPosition;
  48057. private _setTargetMeshVisibility;
  48058. private _showParabolicPath;
  48059. private _teleportForward;
  48060. }
  48061. }
  48062. declare module BABYLON {
  48063. /**
  48064. * Options for the default xr helper
  48065. */
  48066. export class WebXRDefaultExperienceOptions {
  48067. /**
  48068. * Enable or disable default UI to enter XR
  48069. */
  48070. disableDefaultUI?: boolean;
  48071. /**
  48072. * Should teleportation not initialize. defaults to false.
  48073. */
  48074. disableTeleportation?: boolean;
  48075. /**
  48076. * Floor meshes that will be used for teleport
  48077. */
  48078. floorMeshes?: Array<AbstractMesh>;
  48079. /**
  48080. * If set to true, the first frame will not be used to reset position
  48081. * The first frame is mainly used when copying transformation from the old camera
  48082. * Mainly used in AR
  48083. */
  48084. ignoreNativeCameraTransformation?: boolean;
  48085. /**
  48086. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48087. */
  48088. inputOptions?: IWebXRInputOptions;
  48089. /**
  48090. * optional configuration for the output canvas
  48091. */
  48092. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48093. /**
  48094. * optional UI options. This can be used among other to change session mode and reference space type
  48095. */
  48096. uiOptions?: WebXREnterExitUIOptions;
  48097. /**
  48098. * When loading teleportation and pointer select, use stable versions instead of latest.
  48099. */
  48100. useStablePlugins?: boolean;
  48101. /**
  48102. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48103. */
  48104. renderingGroupId?: number;
  48105. /**
  48106. * A list of optional features to init the session with
  48107. * If set to true, all features we support will be added
  48108. */
  48109. optionalFeatures?: boolean | string[];
  48110. }
  48111. /**
  48112. * Default experience which provides a similar setup to the previous webVRExperience
  48113. */
  48114. export class WebXRDefaultExperience {
  48115. /**
  48116. * Base experience
  48117. */
  48118. baseExperience: WebXRExperienceHelper;
  48119. /**
  48120. * Enables ui for entering/exiting xr
  48121. */
  48122. enterExitUI: WebXREnterExitUI;
  48123. /**
  48124. * Input experience extension
  48125. */
  48126. input: WebXRInput;
  48127. /**
  48128. * Enables laser pointer and selection
  48129. */
  48130. pointerSelection: WebXRControllerPointerSelection;
  48131. /**
  48132. * Default target xr should render to
  48133. */
  48134. renderTarget: WebXRRenderTarget;
  48135. /**
  48136. * Enables teleportation
  48137. */
  48138. teleportation: WebXRMotionControllerTeleportation;
  48139. private constructor();
  48140. /**
  48141. * Creates the default xr experience
  48142. * @param scene scene
  48143. * @param options options for basic configuration
  48144. * @returns resulting WebXRDefaultExperience
  48145. */
  48146. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48147. /**
  48148. * DIsposes of the experience helper
  48149. */
  48150. dispose(): void;
  48151. }
  48152. }
  48153. declare module BABYLON {
  48154. /**
  48155. * Options to modify the vr teleportation behavior.
  48156. */
  48157. export interface VRTeleportationOptions {
  48158. /**
  48159. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48160. */
  48161. floorMeshName?: string;
  48162. /**
  48163. * A list of meshes to be used as the teleportation floor. (default: empty)
  48164. */
  48165. floorMeshes?: Mesh[];
  48166. /**
  48167. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48168. */
  48169. teleportationMode?: number;
  48170. /**
  48171. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48172. */
  48173. teleportationTime?: number;
  48174. /**
  48175. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48176. */
  48177. teleportationSpeed?: number;
  48178. /**
  48179. * The easing function used in the animation or null for Linear. (default CircleEase)
  48180. */
  48181. easingFunction?: EasingFunction;
  48182. }
  48183. /**
  48184. * Options to modify the vr experience helper's behavior.
  48185. */
  48186. export interface VRExperienceHelperOptions extends WebVROptions {
  48187. /**
  48188. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48189. */
  48190. createDeviceOrientationCamera?: boolean;
  48191. /**
  48192. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48193. */
  48194. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48195. /**
  48196. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48197. */
  48198. laserToggle?: boolean;
  48199. /**
  48200. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48201. */
  48202. floorMeshes?: Mesh[];
  48203. /**
  48204. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48205. */
  48206. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48207. /**
  48208. * Defines if WebXR should be used instead of WebVR (if available)
  48209. */
  48210. useXR?: boolean;
  48211. }
  48212. /**
  48213. * Event containing information after VR has been entered
  48214. */
  48215. export class OnAfterEnteringVRObservableEvent {
  48216. /**
  48217. * If entering vr was successful
  48218. */
  48219. success: boolean;
  48220. }
  48221. /**
  48222. * Helps to quickly add VR support to an existing scene.
  48223. * See http://doc.babylonjs.com/how_to/webvr_helper
  48224. */
  48225. export class VRExperienceHelper {
  48226. /** Options to modify the vr experience helper's behavior. */
  48227. webVROptions: VRExperienceHelperOptions;
  48228. private _scene;
  48229. private _position;
  48230. private _btnVR;
  48231. private _btnVRDisplayed;
  48232. private _webVRsupported;
  48233. private _webVRready;
  48234. private _webVRrequesting;
  48235. private _webVRpresenting;
  48236. private _hasEnteredVR;
  48237. private _fullscreenVRpresenting;
  48238. private _inputElement;
  48239. private _webVRCamera;
  48240. private _vrDeviceOrientationCamera;
  48241. private _deviceOrientationCamera;
  48242. private _existingCamera;
  48243. private _onKeyDown;
  48244. private _onVrDisplayPresentChange;
  48245. private _onVRDisplayChanged;
  48246. private _onVRRequestPresentStart;
  48247. private _onVRRequestPresentComplete;
  48248. /**
  48249. * 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)
  48250. */
  48251. enableGazeEvenWhenNoPointerLock: boolean;
  48252. /**
  48253. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48254. */
  48255. exitVROnDoubleTap: boolean;
  48256. /**
  48257. * Observable raised right before entering VR.
  48258. */
  48259. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48260. /**
  48261. * Observable raised when entering VR has completed.
  48262. */
  48263. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48264. /**
  48265. * Observable raised when exiting VR.
  48266. */
  48267. onExitingVRObservable: Observable<VRExperienceHelper>;
  48268. /**
  48269. * Observable raised when controller mesh is loaded.
  48270. */
  48271. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48272. /** Return this.onEnteringVRObservable
  48273. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48274. */
  48275. get onEnteringVR(): Observable<VRExperienceHelper>;
  48276. /** Return this.onExitingVRObservable
  48277. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48278. */
  48279. get onExitingVR(): Observable<VRExperienceHelper>;
  48280. /** Return this.onControllerMeshLoadedObservable
  48281. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48282. */
  48283. get onControllerMeshLoaded(): Observable<WebVRController>;
  48284. private _rayLength;
  48285. private _useCustomVRButton;
  48286. private _teleportationRequested;
  48287. private _teleportActive;
  48288. private _floorMeshName;
  48289. private _floorMeshesCollection;
  48290. private _teleportationMode;
  48291. private _teleportationTime;
  48292. private _teleportationSpeed;
  48293. private _teleportationEasing;
  48294. private _rotationAllowed;
  48295. private _teleportBackwardsVector;
  48296. private _teleportationTarget;
  48297. private _isDefaultTeleportationTarget;
  48298. private _postProcessMove;
  48299. private _teleportationFillColor;
  48300. private _teleportationBorderColor;
  48301. private _rotationAngle;
  48302. private _haloCenter;
  48303. private _cameraGazer;
  48304. private _padSensibilityUp;
  48305. private _padSensibilityDown;
  48306. private _leftController;
  48307. private _rightController;
  48308. private _gazeColor;
  48309. private _laserColor;
  48310. private _pickedLaserColor;
  48311. private _pickedGazeColor;
  48312. /**
  48313. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48314. */
  48315. onNewMeshSelected: Observable<AbstractMesh>;
  48316. /**
  48317. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48318. * This observable will provide the mesh and the controller used to select the mesh
  48319. */
  48320. onMeshSelectedWithController: Observable<{
  48321. mesh: AbstractMesh;
  48322. controller: WebVRController;
  48323. }>;
  48324. /**
  48325. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48326. */
  48327. onNewMeshPicked: Observable<PickingInfo>;
  48328. private _circleEase;
  48329. /**
  48330. * Observable raised before camera teleportation
  48331. */
  48332. onBeforeCameraTeleport: Observable<Vector3>;
  48333. /**
  48334. * Observable raised after camera teleportation
  48335. */
  48336. onAfterCameraTeleport: Observable<Vector3>;
  48337. /**
  48338. * Observable raised when current selected mesh gets unselected
  48339. */
  48340. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48341. private _raySelectionPredicate;
  48342. /**
  48343. * To be optionaly changed by user to define custom ray selection
  48344. */
  48345. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48346. /**
  48347. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48348. */
  48349. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48350. /**
  48351. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48352. */
  48353. teleportationEnabled: boolean;
  48354. private _defaultHeight;
  48355. private _teleportationInitialized;
  48356. private _interactionsEnabled;
  48357. private _interactionsRequested;
  48358. private _displayGaze;
  48359. private _displayLaserPointer;
  48360. /**
  48361. * The mesh used to display where the user is going to teleport.
  48362. */
  48363. get teleportationTarget(): Mesh;
  48364. /**
  48365. * Sets the mesh to be used to display where the user is going to teleport.
  48366. */
  48367. set teleportationTarget(value: Mesh);
  48368. /**
  48369. * 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
  48370. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48371. * See http://doc.babylonjs.com/resources/baking_transformations
  48372. */
  48373. get gazeTrackerMesh(): Mesh;
  48374. set gazeTrackerMesh(value: Mesh);
  48375. /**
  48376. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48377. */
  48378. updateGazeTrackerScale: boolean;
  48379. /**
  48380. * If the gaze trackers color should be updated when selecting meshes
  48381. */
  48382. updateGazeTrackerColor: boolean;
  48383. /**
  48384. * If the controller laser color should be updated when selecting meshes
  48385. */
  48386. updateControllerLaserColor: boolean;
  48387. /**
  48388. * The gaze tracking mesh corresponding to the left controller
  48389. */
  48390. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48391. /**
  48392. * The gaze tracking mesh corresponding to the right controller
  48393. */
  48394. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48395. /**
  48396. * If the ray of the gaze should be displayed.
  48397. */
  48398. get displayGaze(): boolean;
  48399. /**
  48400. * Sets if the ray of the gaze should be displayed.
  48401. */
  48402. set displayGaze(value: boolean);
  48403. /**
  48404. * If the ray of the LaserPointer should be displayed.
  48405. */
  48406. get displayLaserPointer(): boolean;
  48407. /**
  48408. * Sets if the ray of the LaserPointer should be displayed.
  48409. */
  48410. set displayLaserPointer(value: boolean);
  48411. /**
  48412. * The deviceOrientationCamera used as the camera when not in VR.
  48413. */
  48414. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48415. /**
  48416. * Based on the current WebVR support, returns the current VR camera used.
  48417. */
  48418. get currentVRCamera(): Nullable<Camera>;
  48419. /**
  48420. * The webVRCamera which is used when in VR.
  48421. */
  48422. get webVRCamera(): WebVRFreeCamera;
  48423. /**
  48424. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48425. */
  48426. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48427. /**
  48428. * The html button that is used to trigger entering into VR.
  48429. */
  48430. get vrButton(): Nullable<HTMLButtonElement>;
  48431. private get _teleportationRequestInitiated();
  48432. /**
  48433. * Defines whether or not Pointer lock should be requested when switching to
  48434. * full screen.
  48435. */
  48436. requestPointerLockOnFullScreen: boolean;
  48437. /**
  48438. * If asking to force XR, this will be populated with the default xr experience
  48439. */
  48440. xr: WebXRDefaultExperience;
  48441. /**
  48442. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48443. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48444. */
  48445. xrTestDone: boolean;
  48446. /**
  48447. * Instantiates a VRExperienceHelper.
  48448. * Helps to quickly add VR support to an existing scene.
  48449. * @param scene The scene the VRExperienceHelper belongs to.
  48450. * @param webVROptions Options to modify the vr experience helper's behavior.
  48451. */
  48452. constructor(scene: Scene,
  48453. /** Options to modify the vr experience helper's behavior. */
  48454. webVROptions?: VRExperienceHelperOptions);
  48455. private completeVRInit;
  48456. private _onDefaultMeshLoaded;
  48457. private _onResize;
  48458. private _onFullscreenChange;
  48459. /**
  48460. * Gets a value indicating if we are currently in VR mode.
  48461. */
  48462. get isInVRMode(): boolean;
  48463. private onVrDisplayPresentChange;
  48464. private onVRDisplayChanged;
  48465. private moveButtonToBottomRight;
  48466. private displayVRButton;
  48467. private updateButtonVisibility;
  48468. private _cachedAngularSensibility;
  48469. /**
  48470. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48471. * Otherwise, will use the fullscreen API.
  48472. */
  48473. enterVR(): void;
  48474. /**
  48475. * Attempt to exit VR, or fullscreen.
  48476. */
  48477. exitVR(): void;
  48478. /**
  48479. * The position of the vr experience helper.
  48480. */
  48481. get position(): Vector3;
  48482. /**
  48483. * Sets the position of the vr experience helper.
  48484. */
  48485. set position(value: Vector3);
  48486. /**
  48487. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48488. */
  48489. enableInteractions(): void;
  48490. private get _noControllerIsActive();
  48491. private beforeRender;
  48492. private _isTeleportationFloor;
  48493. /**
  48494. * Adds a floor mesh to be used for teleportation.
  48495. * @param floorMesh the mesh to be used for teleportation.
  48496. */
  48497. addFloorMesh(floorMesh: Mesh): void;
  48498. /**
  48499. * Removes a floor mesh from being used for teleportation.
  48500. * @param floorMesh the mesh to be removed.
  48501. */
  48502. removeFloorMesh(floorMesh: Mesh): void;
  48503. /**
  48504. * Enables interactions and teleportation using the VR controllers and gaze.
  48505. * @param vrTeleportationOptions options to modify teleportation behavior.
  48506. */
  48507. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48508. private _onNewGamepadConnected;
  48509. private _tryEnableInteractionOnController;
  48510. private _onNewGamepadDisconnected;
  48511. private _enableInteractionOnController;
  48512. private _checkTeleportWithRay;
  48513. private _checkRotate;
  48514. private _checkTeleportBackwards;
  48515. private _enableTeleportationOnController;
  48516. private _createTeleportationCircles;
  48517. private _displayTeleportationTarget;
  48518. private _hideTeleportationTarget;
  48519. private _rotateCamera;
  48520. private _moveTeleportationSelectorTo;
  48521. private _workingVector;
  48522. private _workingQuaternion;
  48523. private _workingMatrix;
  48524. /**
  48525. * Time Constant Teleportation Mode
  48526. */
  48527. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48528. /**
  48529. * Speed Constant Teleportation Mode
  48530. */
  48531. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48532. /**
  48533. * Teleports the users feet to the desired location
  48534. * @param location The location where the user's feet should be placed
  48535. */
  48536. teleportCamera(location: Vector3): void;
  48537. private _convertNormalToDirectionOfRay;
  48538. private _castRayAndSelectObject;
  48539. private _notifySelectedMeshUnselected;
  48540. /**
  48541. * Permanently set new colors for the laser pointer
  48542. * @param color the new laser color
  48543. * @param pickedColor the new laser color when picked mesh detected
  48544. */
  48545. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48546. /**
  48547. * Set lighting enabled / disabled on the laser pointer of both controllers
  48548. * @param enabled should the lighting be enabled on the laser pointer
  48549. */
  48550. setLaserLightingState(enabled?: boolean): void;
  48551. /**
  48552. * Permanently set new colors for the gaze pointer
  48553. * @param color the new gaze color
  48554. * @param pickedColor the new gaze color when picked mesh detected
  48555. */
  48556. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48557. /**
  48558. * Sets the color of the laser ray from the vr controllers.
  48559. * @param color new color for the ray.
  48560. */
  48561. changeLaserColor(color: Color3): void;
  48562. /**
  48563. * Sets the color of the ray from the vr headsets gaze.
  48564. * @param color new color for the ray.
  48565. */
  48566. changeGazeColor(color: Color3): void;
  48567. /**
  48568. * Exits VR and disposes of the vr experience helper
  48569. */
  48570. dispose(): void;
  48571. /**
  48572. * Gets the name of the VRExperienceHelper class
  48573. * @returns "VRExperienceHelper"
  48574. */
  48575. getClassName(): string;
  48576. }
  48577. }
  48578. declare module BABYLON {
  48579. /**
  48580. * Contains an array of blocks representing the octree
  48581. */
  48582. export interface IOctreeContainer<T> {
  48583. /**
  48584. * Blocks within the octree
  48585. */
  48586. blocks: Array<OctreeBlock<T>>;
  48587. }
  48588. /**
  48589. * Class used to store a cell in an octree
  48590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48591. */
  48592. export class OctreeBlock<T> {
  48593. /**
  48594. * Gets the content of the current block
  48595. */
  48596. entries: T[];
  48597. /**
  48598. * Gets the list of block children
  48599. */
  48600. blocks: Array<OctreeBlock<T>>;
  48601. private _depth;
  48602. private _maxDepth;
  48603. private _capacity;
  48604. private _minPoint;
  48605. private _maxPoint;
  48606. private _boundingVectors;
  48607. private _creationFunc;
  48608. /**
  48609. * Creates a new block
  48610. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  48611. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  48612. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48613. * @param depth defines the current depth of this block in the octree
  48614. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  48615. * @param creationFunc defines a callback to call when an element is added to the block
  48616. */
  48617. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  48618. /**
  48619. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  48620. */
  48621. get capacity(): number;
  48622. /**
  48623. * Gets the minimum vector (in world space) of the block's bounding box
  48624. */
  48625. get minPoint(): Vector3;
  48626. /**
  48627. * Gets the maximum vector (in world space) of the block's bounding box
  48628. */
  48629. get maxPoint(): Vector3;
  48630. /**
  48631. * Add a new element to this block
  48632. * @param entry defines the element to add
  48633. */
  48634. addEntry(entry: T): void;
  48635. /**
  48636. * Remove an element from this block
  48637. * @param entry defines the element to remove
  48638. */
  48639. removeEntry(entry: T): void;
  48640. /**
  48641. * Add an array of elements to this block
  48642. * @param entries defines the array of elements to add
  48643. */
  48644. addEntries(entries: T[]): void;
  48645. /**
  48646. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  48647. * @param frustumPlanes defines the frustum planes to test
  48648. * @param selection defines the array to store current content if selection is positive
  48649. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48650. */
  48651. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48652. /**
  48653. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  48654. * @param sphereCenter defines the bounding sphere center
  48655. * @param sphereRadius defines the bounding sphere radius
  48656. * @param selection defines the array to store current content if selection is positive
  48657. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48658. */
  48659. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  48660. /**
  48661. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  48662. * @param ray defines the ray to test with
  48663. * @param selection defines the array to store current content if selection is positive
  48664. */
  48665. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  48666. /**
  48667. * Subdivide the content into child blocks (this block will then be empty)
  48668. */
  48669. createInnerBlocks(): void;
  48670. /**
  48671. * @hidden
  48672. */
  48673. 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;
  48674. }
  48675. }
  48676. declare module BABYLON {
  48677. /**
  48678. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  48679. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48680. */
  48681. export class Octree<T> {
  48682. /** 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.) */
  48683. maxDepth: number;
  48684. /**
  48685. * Blocks within the octree containing objects
  48686. */
  48687. blocks: Array<OctreeBlock<T>>;
  48688. /**
  48689. * Content stored in the octree
  48690. */
  48691. dynamicContent: T[];
  48692. private _maxBlockCapacity;
  48693. private _selectionContent;
  48694. private _creationFunc;
  48695. /**
  48696. * Creates a octree
  48697. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48698. * @param creationFunc function to be used to instatiate the octree
  48699. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  48700. * @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.)
  48701. */
  48702. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  48703. /** 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.) */
  48704. maxDepth?: number);
  48705. /**
  48706. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  48707. * @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);
  48708. * @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);
  48709. * @param entries meshes to be added to the octree blocks
  48710. */
  48711. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  48712. /**
  48713. * Adds a mesh to the octree
  48714. * @param entry Mesh to add to the octree
  48715. */
  48716. addMesh(entry: T): void;
  48717. /**
  48718. * Remove an element from the octree
  48719. * @param entry defines the element to remove
  48720. */
  48721. removeMesh(entry: T): void;
  48722. /**
  48723. * Selects an array of meshes within the frustum
  48724. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  48725. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  48726. * @returns array of meshes within the frustum
  48727. */
  48728. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  48729. /**
  48730. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  48731. * @param sphereCenter defines the bounding sphere center
  48732. * @param sphereRadius defines the bounding sphere radius
  48733. * @param allowDuplicate defines if the selection array can contains duplicated entries
  48734. * @returns an array of objects that intersect the sphere
  48735. */
  48736. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  48737. /**
  48738. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  48739. * @param ray defines the ray to test with
  48740. * @returns array of intersected objects
  48741. */
  48742. intersectsRay(ray: Ray): SmartArray<T>;
  48743. /**
  48744. * Adds a mesh into the octree block if it intersects the block
  48745. */
  48746. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  48747. /**
  48748. * Adds a submesh into the octree block if it intersects the block
  48749. */
  48750. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  48751. }
  48752. }
  48753. declare module BABYLON {
  48754. interface Scene {
  48755. /**
  48756. * @hidden
  48757. * Backing Filed
  48758. */
  48759. _selectionOctree: Octree<AbstractMesh>;
  48760. /**
  48761. * Gets the octree used to boost mesh selection (picking)
  48762. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48763. */
  48764. selectionOctree: Octree<AbstractMesh>;
  48765. /**
  48766. * Creates or updates the octree used to boost selection (picking)
  48767. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48768. * @param maxCapacity defines the maximum capacity per leaf
  48769. * @param maxDepth defines the maximum depth of the octree
  48770. * @returns an octree of AbstractMesh
  48771. */
  48772. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  48773. }
  48774. interface AbstractMesh {
  48775. /**
  48776. * @hidden
  48777. * Backing Field
  48778. */
  48779. _submeshesOctree: Octree<SubMesh>;
  48780. /**
  48781. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  48782. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  48783. * @param maxCapacity defines the maximum size of each block (64 by default)
  48784. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  48785. * @returns the new octree
  48786. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  48787. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48788. */
  48789. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  48790. }
  48791. /**
  48792. * Defines the octree scene component responsible to manage any octrees
  48793. * in a given scene.
  48794. */
  48795. export class OctreeSceneComponent {
  48796. /**
  48797. * The component name help to identify the component in the list of scene components.
  48798. */
  48799. readonly name: string;
  48800. /**
  48801. * The scene the component belongs to.
  48802. */
  48803. scene: Scene;
  48804. /**
  48805. * Indicates if the meshes have been checked to make sure they are isEnabled()
  48806. */
  48807. readonly checksIsEnabled: boolean;
  48808. /**
  48809. * Creates a new instance of the component for the given scene
  48810. * @param scene Defines the scene to register the component in
  48811. */
  48812. constructor(scene: Scene);
  48813. /**
  48814. * Registers the component in a given scene
  48815. */
  48816. register(): void;
  48817. /**
  48818. * Return the list of active meshes
  48819. * @returns the list of active meshes
  48820. */
  48821. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  48822. /**
  48823. * Return the list of active sub meshes
  48824. * @param mesh The mesh to get the candidates sub meshes from
  48825. * @returns the list of active sub meshes
  48826. */
  48827. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  48828. private _tempRay;
  48829. /**
  48830. * Return the list of sub meshes intersecting with a given local ray
  48831. * @param mesh defines the mesh to find the submesh for
  48832. * @param localRay defines the ray in local space
  48833. * @returns the list of intersecting sub meshes
  48834. */
  48835. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  48836. /**
  48837. * Return the list of sub meshes colliding with a collider
  48838. * @param mesh defines the mesh to find the submesh for
  48839. * @param collider defines the collider to evaluate the collision against
  48840. * @returns the list of colliding sub meshes
  48841. */
  48842. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  48843. /**
  48844. * Rebuilds the elements related to this component in case of
  48845. * context lost for instance.
  48846. */
  48847. rebuild(): void;
  48848. /**
  48849. * Disposes the component and the associated ressources.
  48850. */
  48851. dispose(): void;
  48852. }
  48853. }
  48854. declare module BABYLON {
  48855. /**
  48856. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  48857. */
  48858. export class Gizmo implements IDisposable {
  48859. /** The utility layer the gizmo will be added to */
  48860. gizmoLayer: UtilityLayerRenderer;
  48861. /**
  48862. * The root mesh of the gizmo
  48863. */
  48864. _rootMesh: Mesh;
  48865. private _attachedMesh;
  48866. /**
  48867. * Ratio for the scale of the gizmo (Default: 1)
  48868. */
  48869. scaleRatio: number;
  48870. /**
  48871. * If a custom mesh has been set (Default: false)
  48872. */
  48873. protected _customMeshSet: boolean;
  48874. /**
  48875. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  48876. * * When set, interactions will be enabled
  48877. */
  48878. get attachedMesh(): Nullable<AbstractMesh>;
  48879. set attachedMesh(value: Nullable<AbstractMesh>);
  48880. /**
  48881. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48882. * @param mesh The mesh to replace the default mesh of the gizmo
  48883. */
  48884. setCustomMesh(mesh: Mesh): void;
  48885. /**
  48886. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  48887. */
  48888. updateGizmoRotationToMatchAttachedMesh: boolean;
  48889. /**
  48890. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  48891. */
  48892. updateGizmoPositionToMatchAttachedMesh: boolean;
  48893. /**
  48894. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  48895. */
  48896. updateScale: boolean;
  48897. protected _interactionsEnabled: boolean;
  48898. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48899. private _beforeRenderObserver;
  48900. private _tempVector;
  48901. /**
  48902. * Creates a gizmo
  48903. * @param gizmoLayer The utility layer the gizmo will be added to
  48904. */
  48905. constructor(
  48906. /** The utility layer the gizmo will be added to */
  48907. gizmoLayer?: UtilityLayerRenderer);
  48908. /**
  48909. * Updates the gizmo to match the attached mesh's position/rotation
  48910. */
  48911. protected _update(): void;
  48912. /**
  48913. * Disposes of the gizmo
  48914. */
  48915. dispose(): void;
  48916. }
  48917. }
  48918. declare module BABYLON {
  48919. /**
  48920. * Single plane drag gizmo
  48921. */
  48922. export class PlaneDragGizmo extends Gizmo {
  48923. /**
  48924. * Drag behavior responsible for the gizmos dragging interactions
  48925. */
  48926. dragBehavior: PointerDragBehavior;
  48927. private _pointerObserver;
  48928. /**
  48929. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48930. */
  48931. snapDistance: number;
  48932. /**
  48933. * Event that fires each time the gizmo snaps to a new location.
  48934. * * snapDistance is the the change in distance
  48935. */
  48936. onSnapObservable: Observable<{
  48937. snapDistance: number;
  48938. }>;
  48939. private _plane;
  48940. private _coloredMaterial;
  48941. private _hoverMaterial;
  48942. private _isEnabled;
  48943. private _parent;
  48944. /** @hidden */
  48945. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  48946. /** @hidden */
  48947. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48948. /**
  48949. * Creates a PlaneDragGizmo
  48950. * @param gizmoLayer The utility layer the gizmo will be added to
  48951. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  48952. * @param color The color of the gizmo
  48953. */
  48954. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48955. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48956. /**
  48957. * If the gizmo is enabled
  48958. */
  48959. set isEnabled(value: boolean);
  48960. get isEnabled(): boolean;
  48961. /**
  48962. * Disposes of the gizmo
  48963. */
  48964. dispose(): void;
  48965. }
  48966. }
  48967. declare module BABYLON {
  48968. /**
  48969. * Gizmo that enables dragging a mesh along 3 axis
  48970. */
  48971. export class PositionGizmo extends Gizmo {
  48972. /**
  48973. * Internal gizmo used for interactions on the x axis
  48974. */
  48975. xGizmo: AxisDragGizmo;
  48976. /**
  48977. * Internal gizmo used for interactions on the y axis
  48978. */
  48979. yGizmo: AxisDragGizmo;
  48980. /**
  48981. * Internal gizmo used for interactions on the z axis
  48982. */
  48983. zGizmo: AxisDragGizmo;
  48984. /**
  48985. * Internal gizmo used for interactions on the yz plane
  48986. */
  48987. xPlaneGizmo: PlaneDragGizmo;
  48988. /**
  48989. * Internal gizmo used for interactions on the xz plane
  48990. */
  48991. yPlaneGizmo: PlaneDragGizmo;
  48992. /**
  48993. * Internal gizmo used for interactions on the xy plane
  48994. */
  48995. zPlaneGizmo: PlaneDragGizmo;
  48996. /**
  48997. * private variables
  48998. */
  48999. private _meshAttached;
  49000. private _updateGizmoRotationToMatchAttachedMesh;
  49001. private _snapDistance;
  49002. private _scaleRatio;
  49003. /** Fires an event when any of it's sub gizmos are dragged */
  49004. onDragStartObservable: Observable<unknown>;
  49005. /** Fires an event when any of it's sub gizmos are released from dragging */
  49006. onDragEndObservable: Observable<unknown>;
  49007. /**
  49008. * If set to true, planar drag is enabled
  49009. */
  49010. private _planarGizmoEnabled;
  49011. get attachedMesh(): Nullable<AbstractMesh>;
  49012. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49013. /**
  49014. * Creates a PositionGizmo
  49015. * @param gizmoLayer The utility layer the gizmo will be added to
  49016. */
  49017. constructor(gizmoLayer?: UtilityLayerRenderer);
  49018. /**
  49019. * If the planar drag gizmo is enabled
  49020. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49021. */
  49022. set planarGizmoEnabled(value: boolean);
  49023. get planarGizmoEnabled(): boolean;
  49024. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49025. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49026. /**
  49027. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49028. */
  49029. set snapDistance(value: number);
  49030. get snapDistance(): number;
  49031. /**
  49032. * Ratio for the scale of the gizmo (Default: 1)
  49033. */
  49034. set scaleRatio(value: number);
  49035. get scaleRatio(): number;
  49036. /**
  49037. * Disposes of the gizmo
  49038. */
  49039. dispose(): void;
  49040. /**
  49041. * CustomMeshes are not supported by this gizmo
  49042. * @param mesh The mesh to replace the default mesh of the gizmo
  49043. */
  49044. setCustomMesh(mesh: Mesh): void;
  49045. }
  49046. }
  49047. declare module BABYLON {
  49048. /**
  49049. * Single axis drag gizmo
  49050. */
  49051. export class AxisDragGizmo extends Gizmo {
  49052. /**
  49053. * Drag behavior responsible for the gizmos dragging interactions
  49054. */
  49055. dragBehavior: PointerDragBehavior;
  49056. private _pointerObserver;
  49057. /**
  49058. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49059. */
  49060. snapDistance: number;
  49061. /**
  49062. * Event that fires each time the gizmo snaps to a new location.
  49063. * * snapDistance is the the change in distance
  49064. */
  49065. onSnapObservable: Observable<{
  49066. snapDistance: number;
  49067. }>;
  49068. private _isEnabled;
  49069. private _parent;
  49070. private _arrow;
  49071. private _coloredMaterial;
  49072. private _hoverMaterial;
  49073. /** @hidden */
  49074. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49075. /** @hidden */
  49076. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49077. /**
  49078. * Creates an AxisDragGizmo
  49079. * @param gizmoLayer The utility layer the gizmo will be added to
  49080. * @param dragAxis The axis which the gizmo will be able to drag on
  49081. * @param color The color of the gizmo
  49082. */
  49083. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49084. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49085. /**
  49086. * If the gizmo is enabled
  49087. */
  49088. set isEnabled(value: boolean);
  49089. get isEnabled(): boolean;
  49090. /**
  49091. * Disposes of the gizmo
  49092. */
  49093. dispose(): void;
  49094. }
  49095. }
  49096. declare module BABYLON.Debug {
  49097. /**
  49098. * The Axes viewer will show 3 axes in a specific point in space
  49099. */
  49100. export class AxesViewer {
  49101. private _xAxis;
  49102. private _yAxis;
  49103. private _zAxis;
  49104. private _scaleLinesFactor;
  49105. private _instanced;
  49106. /**
  49107. * Gets the hosting scene
  49108. */
  49109. scene: Scene;
  49110. /**
  49111. * Gets or sets a number used to scale line length
  49112. */
  49113. scaleLines: number;
  49114. /** Gets the node hierarchy used to render x-axis */
  49115. get xAxis(): TransformNode;
  49116. /** Gets the node hierarchy used to render y-axis */
  49117. get yAxis(): TransformNode;
  49118. /** Gets the node hierarchy used to render z-axis */
  49119. get zAxis(): TransformNode;
  49120. /**
  49121. * Creates a new AxesViewer
  49122. * @param scene defines the hosting scene
  49123. * @param scaleLines defines a number used to scale line length (1 by default)
  49124. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49125. * @param xAxis defines the node hierarchy used to render the x-axis
  49126. * @param yAxis defines the node hierarchy used to render the y-axis
  49127. * @param zAxis defines the node hierarchy used to render the z-axis
  49128. */
  49129. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49130. /**
  49131. * Force the viewer to update
  49132. * @param position defines the position of the viewer
  49133. * @param xaxis defines the x axis of the viewer
  49134. * @param yaxis defines the y axis of the viewer
  49135. * @param zaxis defines the z axis of the viewer
  49136. */
  49137. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49138. /**
  49139. * Creates an instance of this axes viewer.
  49140. * @returns a new axes viewer with instanced meshes
  49141. */
  49142. createInstance(): AxesViewer;
  49143. /** Releases resources */
  49144. dispose(): void;
  49145. private static _SetRenderingGroupId;
  49146. }
  49147. }
  49148. declare module BABYLON.Debug {
  49149. /**
  49150. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49151. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49152. */
  49153. export class BoneAxesViewer extends AxesViewer {
  49154. /**
  49155. * Gets or sets the target mesh where to display the axes viewer
  49156. */
  49157. mesh: Nullable<Mesh>;
  49158. /**
  49159. * Gets or sets the target bone where to display the axes viewer
  49160. */
  49161. bone: Nullable<Bone>;
  49162. /** Gets current position */
  49163. pos: Vector3;
  49164. /** Gets direction of X axis */
  49165. xaxis: Vector3;
  49166. /** Gets direction of Y axis */
  49167. yaxis: Vector3;
  49168. /** Gets direction of Z axis */
  49169. zaxis: Vector3;
  49170. /**
  49171. * Creates a new BoneAxesViewer
  49172. * @param scene defines the hosting scene
  49173. * @param bone defines the target bone
  49174. * @param mesh defines the target mesh
  49175. * @param scaleLines defines a scaling factor for line length (1 by default)
  49176. */
  49177. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49178. /**
  49179. * Force the viewer to update
  49180. */
  49181. update(): void;
  49182. /** Releases resources */
  49183. dispose(): void;
  49184. }
  49185. }
  49186. declare module BABYLON {
  49187. /**
  49188. * Interface used to define scene explorer extensibility option
  49189. */
  49190. export interface IExplorerExtensibilityOption {
  49191. /**
  49192. * Define the option label
  49193. */
  49194. label: string;
  49195. /**
  49196. * Defines the action to execute on click
  49197. */
  49198. action: (entity: any) => void;
  49199. }
  49200. /**
  49201. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49202. */
  49203. export interface IExplorerExtensibilityGroup {
  49204. /**
  49205. * Defines a predicate to test if a given type mut be extended
  49206. */
  49207. predicate: (entity: any) => boolean;
  49208. /**
  49209. * Gets the list of options added to a type
  49210. */
  49211. entries: IExplorerExtensibilityOption[];
  49212. }
  49213. /**
  49214. * Interface used to define the options to use to create the Inspector
  49215. */
  49216. export interface IInspectorOptions {
  49217. /**
  49218. * Display in overlay mode (default: false)
  49219. */
  49220. overlay?: boolean;
  49221. /**
  49222. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49223. */
  49224. globalRoot?: HTMLElement;
  49225. /**
  49226. * Display the Scene explorer
  49227. */
  49228. showExplorer?: boolean;
  49229. /**
  49230. * Display the property inspector
  49231. */
  49232. showInspector?: boolean;
  49233. /**
  49234. * Display in embed mode (both panes on the right)
  49235. */
  49236. embedMode?: boolean;
  49237. /**
  49238. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49239. */
  49240. handleResize?: boolean;
  49241. /**
  49242. * Allow the panes to popup (default: true)
  49243. */
  49244. enablePopup?: boolean;
  49245. /**
  49246. * Allow the panes to be closed by users (default: true)
  49247. */
  49248. enableClose?: boolean;
  49249. /**
  49250. * Optional list of extensibility entries
  49251. */
  49252. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49253. /**
  49254. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49255. */
  49256. inspectorURL?: string;
  49257. /**
  49258. * Optional initial tab (default to DebugLayerTab.Properties)
  49259. */
  49260. initialTab?: DebugLayerTab;
  49261. }
  49262. interface Scene {
  49263. /**
  49264. * @hidden
  49265. * Backing field
  49266. */
  49267. _debugLayer: DebugLayer;
  49268. /**
  49269. * Gets the debug layer (aka Inspector) associated with the scene
  49270. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49271. */
  49272. debugLayer: DebugLayer;
  49273. }
  49274. /**
  49275. * Enum of inspector action tab
  49276. */
  49277. export enum DebugLayerTab {
  49278. /**
  49279. * Properties tag (default)
  49280. */
  49281. Properties = 0,
  49282. /**
  49283. * Debug tab
  49284. */
  49285. Debug = 1,
  49286. /**
  49287. * Statistics tab
  49288. */
  49289. Statistics = 2,
  49290. /**
  49291. * Tools tab
  49292. */
  49293. Tools = 3,
  49294. /**
  49295. * Settings tab
  49296. */
  49297. Settings = 4
  49298. }
  49299. /**
  49300. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49301. * what is happening in your scene
  49302. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49303. */
  49304. export class DebugLayer {
  49305. /**
  49306. * Define the url to get the inspector script from.
  49307. * By default it uses the babylonjs CDN.
  49308. * @ignoreNaming
  49309. */
  49310. static InspectorURL: string;
  49311. private _scene;
  49312. private BJSINSPECTOR;
  49313. private _onPropertyChangedObservable?;
  49314. /**
  49315. * Observable triggered when a property is changed through the inspector.
  49316. */
  49317. get onPropertyChangedObservable(): any;
  49318. /**
  49319. * Instantiates a new debug layer.
  49320. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49321. * what is happening in your scene
  49322. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49323. * @param scene Defines the scene to inspect
  49324. */
  49325. constructor(scene: Scene);
  49326. /** Creates the inspector window. */
  49327. private _createInspector;
  49328. /**
  49329. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49330. * @param entity defines the entity to select
  49331. * @param lineContainerTitle defines the specific block to highlight
  49332. */
  49333. select(entity: any, lineContainerTitle?: string): void;
  49334. /** Get the inspector from bundle or global */
  49335. private _getGlobalInspector;
  49336. /**
  49337. * Get if the inspector is visible or not.
  49338. * @returns true if visible otherwise, false
  49339. */
  49340. isVisible(): boolean;
  49341. /**
  49342. * Hide the inspector and close its window.
  49343. */
  49344. hide(): void;
  49345. /**
  49346. * Update the scene in the inspector
  49347. */
  49348. setAsActiveScene(): void;
  49349. /**
  49350. * Launch the debugLayer.
  49351. * @param config Define the configuration of the inspector
  49352. * @return a promise fulfilled when the debug layer is visible
  49353. */
  49354. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49355. }
  49356. }
  49357. declare module BABYLON {
  49358. /**
  49359. * Class containing static functions to help procedurally build meshes
  49360. */
  49361. export class BoxBuilder {
  49362. /**
  49363. * Creates a box mesh
  49364. * * The parameter `size` sets the size (float) of each box side (default 1)
  49365. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49366. * * 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)
  49367. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49369. * * 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
  49370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49371. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49372. * @param name defines the name of the mesh
  49373. * @param options defines the options used to create the mesh
  49374. * @param scene defines the hosting scene
  49375. * @returns the box mesh
  49376. */
  49377. static CreateBox(name: string, options: {
  49378. size?: number;
  49379. width?: number;
  49380. height?: number;
  49381. depth?: number;
  49382. faceUV?: Vector4[];
  49383. faceColors?: Color4[];
  49384. sideOrientation?: number;
  49385. frontUVs?: Vector4;
  49386. backUVs?: Vector4;
  49387. wrap?: boolean;
  49388. topBaseAt?: number;
  49389. bottomBaseAt?: number;
  49390. updatable?: boolean;
  49391. }, scene?: Nullable<Scene>): Mesh;
  49392. }
  49393. }
  49394. declare module BABYLON.Debug {
  49395. /**
  49396. * Used to show the physics impostor around the specific mesh
  49397. */
  49398. export class PhysicsViewer {
  49399. /** @hidden */
  49400. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49401. /** @hidden */
  49402. protected _meshes: Array<Nullable<AbstractMesh>>;
  49403. /** @hidden */
  49404. protected _scene: Nullable<Scene>;
  49405. /** @hidden */
  49406. protected _numMeshes: number;
  49407. /** @hidden */
  49408. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49409. private _renderFunction;
  49410. private _utilityLayer;
  49411. private _debugBoxMesh;
  49412. private _debugSphereMesh;
  49413. private _debugCylinderMesh;
  49414. private _debugMaterial;
  49415. private _debugMeshMeshes;
  49416. /**
  49417. * Creates a new PhysicsViewer
  49418. * @param scene defines the hosting scene
  49419. */
  49420. constructor(scene: Scene);
  49421. /** @hidden */
  49422. protected _updateDebugMeshes(): void;
  49423. /**
  49424. * Renders a specified physic impostor
  49425. * @param impostor defines the impostor to render
  49426. * @param targetMesh defines the mesh represented by the impostor
  49427. * @returns the new debug mesh used to render the impostor
  49428. */
  49429. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49430. /**
  49431. * Hides a specified physic impostor
  49432. * @param impostor defines the impostor to hide
  49433. */
  49434. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49435. private _getDebugMaterial;
  49436. private _getDebugBoxMesh;
  49437. private _getDebugSphereMesh;
  49438. private _getDebugCylinderMesh;
  49439. private _getDebugMeshMesh;
  49440. private _getDebugMesh;
  49441. /** Releases all resources */
  49442. dispose(): void;
  49443. }
  49444. }
  49445. declare module BABYLON {
  49446. /**
  49447. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49448. * in order to better appreciate the issue one might have.
  49449. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49450. */
  49451. export class RayHelper {
  49452. /**
  49453. * Defines the ray we are currently tryin to visualize.
  49454. */
  49455. ray: Nullable<Ray>;
  49456. private _renderPoints;
  49457. private _renderLine;
  49458. private _renderFunction;
  49459. private _scene;
  49460. private _updateToMeshFunction;
  49461. private _attachedToMesh;
  49462. private _meshSpaceDirection;
  49463. private _meshSpaceOrigin;
  49464. /**
  49465. * Helper function to create a colored helper in a scene in one line.
  49466. * @param ray Defines the ray we are currently tryin to visualize
  49467. * @param scene Defines the scene the ray is used in
  49468. * @param color Defines the color we want to see the ray in
  49469. * @returns The newly created ray helper.
  49470. */
  49471. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49472. /**
  49473. * Instantiate a new ray helper.
  49474. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49475. * in order to better appreciate the issue one might have.
  49476. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49477. * @param ray Defines the ray we are currently tryin to visualize
  49478. */
  49479. constructor(ray: Ray);
  49480. /**
  49481. * Shows the ray we are willing to debug.
  49482. * @param scene Defines the scene the ray needs to be rendered in
  49483. * @param color Defines the color the ray needs to be rendered in
  49484. */
  49485. show(scene: Scene, color?: Color3): void;
  49486. /**
  49487. * Hides the ray we are debugging.
  49488. */
  49489. hide(): void;
  49490. private _render;
  49491. /**
  49492. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49493. * @param mesh Defines the mesh we want the helper attached to
  49494. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49495. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49496. * @param length Defines the length of the ray
  49497. */
  49498. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49499. /**
  49500. * Detach the ray helper from the mesh it has previously been attached to.
  49501. */
  49502. detachFromMesh(): void;
  49503. private _updateToMesh;
  49504. /**
  49505. * Dispose the helper and release its associated resources.
  49506. */
  49507. dispose(): void;
  49508. }
  49509. }
  49510. declare module BABYLON.Debug {
  49511. /**
  49512. * Class used to render a debug view of a given skeleton
  49513. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49514. */
  49515. export class SkeletonViewer {
  49516. /** defines the skeleton to render */
  49517. skeleton: Skeleton;
  49518. /** defines the mesh attached to the skeleton */
  49519. mesh: AbstractMesh;
  49520. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49521. autoUpdateBonesMatrices: boolean;
  49522. /** defines the rendering group id to use with the viewer */
  49523. renderingGroupId: number;
  49524. /** Gets or sets the color used to render the skeleton */
  49525. color: Color3;
  49526. private _scene;
  49527. private _debugLines;
  49528. private _debugMesh;
  49529. private _isEnabled;
  49530. private _renderFunction;
  49531. private _utilityLayer;
  49532. /**
  49533. * Returns the mesh used to render the bones
  49534. */
  49535. get debugMesh(): Nullable<LinesMesh>;
  49536. /**
  49537. * Creates a new SkeletonViewer
  49538. * @param skeleton defines the skeleton to render
  49539. * @param mesh defines the mesh attached to the skeleton
  49540. * @param scene defines the hosting scene
  49541. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49542. * @param renderingGroupId defines the rendering group id to use with the viewer
  49543. */
  49544. constructor(
  49545. /** defines the skeleton to render */
  49546. skeleton: Skeleton,
  49547. /** defines the mesh attached to the skeleton */
  49548. mesh: AbstractMesh, scene: Scene,
  49549. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49550. autoUpdateBonesMatrices?: boolean,
  49551. /** defines the rendering group id to use with the viewer */
  49552. renderingGroupId?: number);
  49553. /** Gets or sets a boolean indicating if the viewer is enabled */
  49554. set isEnabled(value: boolean);
  49555. get isEnabled(): boolean;
  49556. private _getBonePosition;
  49557. private _getLinesForBonesWithLength;
  49558. private _getLinesForBonesNoLength;
  49559. /** Update the viewer to sync with current skeleton state */
  49560. update(): void;
  49561. /** Release associated resources */
  49562. dispose(): void;
  49563. }
  49564. }
  49565. declare module BABYLON {
  49566. /**
  49567. * Enum for Device Types
  49568. */
  49569. export enum DeviceType {
  49570. /** Generic */
  49571. Generic = 0,
  49572. /** Keyboard */
  49573. Keyboard = 1,
  49574. /** Mouse */
  49575. Mouse = 2,
  49576. /** Touch Pointers */
  49577. Touch = 3,
  49578. /** PS4 Dual Shock */
  49579. DualShock = 4,
  49580. /** Xbox */
  49581. Xbox = 5,
  49582. /** Switch Controller */
  49583. Switch = 6
  49584. }
  49585. /**
  49586. * Enum for All Pointers (Touch/Mouse)
  49587. */
  49588. export enum PointerInput {
  49589. /** Horizontal Axis */
  49590. Horizontal = 0,
  49591. /** Vertical Axis */
  49592. Vertical = 1,
  49593. /** Left Click or Touch */
  49594. LeftClick = 2,
  49595. /** Middle Click */
  49596. MiddleClick = 3,
  49597. /** Right Click */
  49598. RightClick = 4,
  49599. /** Browser Back */
  49600. BrowserBack = 5,
  49601. /** Browser Forward */
  49602. BrowserForward = 6
  49603. }
  49604. /**
  49605. * Enum for Dual Shock Gamepad
  49606. */
  49607. export enum DualShockInput {
  49608. /** Cross */
  49609. Cross = 0,
  49610. /** Circle */
  49611. Circle = 1,
  49612. /** Square */
  49613. Square = 2,
  49614. /** Triangle */
  49615. Triangle = 3,
  49616. /** L1 */
  49617. L1 = 4,
  49618. /** R1 */
  49619. R1 = 5,
  49620. /** L2 */
  49621. L2 = 6,
  49622. /** R2 */
  49623. R2 = 7,
  49624. /** Share */
  49625. Share = 8,
  49626. /** Options */
  49627. Options = 9,
  49628. /** L3 */
  49629. L3 = 10,
  49630. /** R3 */
  49631. R3 = 11,
  49632. /** DPadUp */
  49633. DPadUp = 12,
  49634. /** DPadDown */
  49635. DPadDown = 13,
  49636. /** DPadLeft */
  49637. DPadLeft = 14,
  49638. /** DRight */
  49639. DPadRight = 15,
  49640. /** Home */
  49641. Home = 16,
  49642. /** TouchPad */
  49643. TouchPad = 17,
  49644. /** LStickXAxis */
  49645. LStickXAxis = 18,
  49646. /** LStickYAxis */
  49647. LStickYAxis = 19,
  49648. /** RStickXAxis */
  49649. RStickXAxis = 20,
  49650. /** RStickYAxis */
  49651. RStickYAxis = 21
  49652. }
  49653. /**
  49654. * Enum for Xbox Gamepad
  49655. */
  49656. export enum XboxInput {
  49657. /** A */
  49658. A = 0,
  49659. /** B */
  49660. B = 1,
  49661. /** X */
  49662. X = 2,
  49663. /** Y */
  49664. Y = 3,
  49665. /** LB */
  49666. LB = 4,
  49667. /** RB */
  49668. RB = 5,
  49669. /** LT */
  49670. LT = 6,
  49671. /** RT */
  49672. RT = 7,
  49673. /** Back */
  49674. Back = 8,
  49675. /** Start */
  49676. Start = 9,
  49677. /** LS */
  49678. LS = 10,
  49679. /** RS */
  49680. RS = 11,
  49681. /** DPadUp */
  49682. DPadUp = 12,
  49683. /** DPadDown */
  49684. DPadDown = 13,
  49685. /** DPadLeft */
  49686. DPadLeft = 14,
  49687. /** DRight */
  49688. DPadRight = 15,
  49689. /** Home */
  49690. Home = 16,
  49691. /** LStickXAxis */
  49692. LStickXAxis = 17,
  49693. /** LStickYAxis */
  49694. LStickYAxis = 18,
  49695. /** RStickXAxis */
  49696. RStickXAxis = 19,
  49697. /** RStickYAxis */
  49698. RStickYAxis = 20
  49699. }
  49700. /**
  49701. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  49702. */
  49703. export enum SwitchInput {
  49704. /** B */
  49705. B = 0,
  49706. /** A */
  49707. A = 1,
  49708. /** Y */
  49709. Y = 2,
  49710. /** X */
  49711. X = 3,
  49712. /** L */
  49713. L = 4,
  49714. /** R */
  49715. R = 5,
  49716. /** ZL */
  49717. ZL = 6,
  49718. /** ZR */
  49719. ZR = 7,
  49720. /** Minus */
  49721. Minus = 8,
  49722. /** Plus */
  49723. Plus = 9,
  49724. /** LS */
  49725. LS = 10,
  49726. /** RS */
  49727. RS = 11,
  49728. /** DPadUp */
  49729. DPadUp = 12,
  49730. /** DPadDown */
  49731. DPadDown = 13,
  49732. /** DPadLeft */
  49733. DPadLeft = 14,
  49734. /** DRight */
  49735. DPadRight = 15,
  49736. /** Home */
  49737. Home = 16,
  49738. /** Capture */
  49739. Capture = 17,
  49740. /** LStickXAxis */
  49741. LStickXAxis = 18,
  49742. /** LStickYAxis */
  49743. LStickYAxis = 19,
  49744. /** RStickXAxis */
  49745. RStickXAxis = 20,
  49746. /** RStickYAxis */
  49747. RStickYAxis = 21
  49748. }
  49749. }
  49750. declare module BABYLON {
  49751. /**
  49752. * This class will take all inputs from Keyboard, Pointer, and
  49753. * any Gamepads and provide a polling system that all devices
  49754. * will use. This class assumes that there will only be one
  49755. * pointer device and one keyboard.
  49756. */
  49757. export class DeviceInputSystem implements IDisposable {
  49758. /**
  49759. * Callback to be triggered when a device is connected
  49760. */
  49761. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49762. /**
  49763. * Callback to be triggered when a device is disconnected
  49764. */
  49765. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  49766. /**
  49767. * Callback to be triggered when event driven input is updated
  49768. */
  49769. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  49770. private _inputs;
  49771. private _gamepads;
  49772. private _keyboardActive;
  49773. private _pointerActive;
  49774. private _elementToAttachTo;
  49775. private _keyboardDownEvent;
  49776. private _keyboardUpEvent;
  49777. private _pointerMoveEvent;
  49778. private _pointerDownEvent;
  49779. private _pointerUpEvent;
  49780. private _gamepadConnectedEvent;
  49781. private _gamepadDisconnectedEvent;
  49782. private static _MAX_KEYCODES;
  49783. private static _MAX_POINTER_INPUTS;
  49784. /**
  49785. * Default Constructor
  49786. * @param engine - engine to pull input element from
  49787. */
  49788. constructor(engine: Engine);
  49789. /**
  49790. * Checks for current device input value, given an id and input index
  49791. * @param deviceName Id of connected device
  49792. * @param inputIndex Index of device input
  49793. * @returns Current value of input
  49794. */
  49795. /**
  49796. * Checks for current device input value, given an id and input index
  49797. * @param deviceType Enum specifiying device type
  49798. * @param deviceSlot "Slot" or index that device is referenced in
  49799. * @param inputIndex Id of input to be checked
  49800. * @returns Current value of input
  49801. */
  49802. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  49803. /**
  49804. * Dispose of all the eventlisteners
  49805. */
  49806. dispose(): void;
  49807. /**
  49808. * Add device and inputs to device array
  49809. * @param deviceType Enum specifiying device type
  49810. * @param deviceSlot "Slot" or index that device is referenced in
  49811. * @param numberOfInputs Number of input entries to create for given device
  49812. */
  49813. private _registerDevice;
  49814. /**
  49815. * Given a specific device name, remove that device from the device map
  49816. * @param deviceType Enum specifiying device type
  49817. * @param deviceSlot "Slot" or index that device is referenced in
  49818. */
  49819. private _unregisterDevice;
  49820. /**
  49821. * Handle all actions that come from keyboard interaction
  49822. */
  49823. private _handleKeyActions;
  49824. /**
  49825. * Handle all actions that come from pointer interaction
  49826. */
  49827. private _handlePointerActions;
  49828. /**
  49829. * Handle all actions that come from gamepad interaction
  49830. */
  49831. private _handleGamepadActions;
  49832. /**
  49833. * Update all non-event based devices with each frame
  49834. * @param deviceType Enum specifiying device type
  49835. * @param deviceSlot "Slot" or index that device is referenced in
  49836. * @param inputIndex Id of input to be checked
  49837. */
  49838. private _updateDevice;
  49839. /**
  49840. * Gets DeviceType from the device name
  49841. * @param deviceName Name of Device from DeviceInputSystem
  49842. * @returns DeviceType enum value
  49843. */
  49844. private _getGamepadDeviceType;
  49845. }
  49846. }
  49847. declare module BABYLON {
  49848. /**
  49849. * Type to handle enforcement of inputs
  49850. */
  49851. 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;
  49852. }
  49853. declare module BABYLON {
  49854. /**
  49855. * Class that handles all input for a specific device
  49856. */
  49857. export class DeviceSource<T extends DeviceType> {
  49858. /** Type of device */
  49859. readonly deviceType: DeviceType;
  49860. /** "Slot" or index that device is referenced in */
  49861. readonly deviceSlot: number;
  49862. /**
  49863. * Observable to handle device input changes per device
  49864. */
  49865. readonly onInputChangedObservable: Observable<{
  49866. inputIndex: DeviceInput<T>;
  49867. previousState: Nullable<number>;
  49868. currentState: Nullable<number>;
  49869. }>;
  49870. private readonly _deviceInputSystem;
  49871. /**
  49872. * Default Constructor
  49873. * @param deviceInputSystem Reference to DeviceInputSystem
  49874. * @param deviceType Type of device
  49875. * @param deviceSlot "Slot" or index that device is referenced in
  49876. */
  49877. constructor(deviceInputSystem: DeviceInputSystem,
  49878. /** Type of device */
  49879. deviceType: DeviceType,
  49880. /** "Slot" or index that device is referenced in */
  49881. deviceSlot?: number);
  49882. /**
  49883. * Get input for specific input
  49884. * @param inputIndex index of specific input on device
  49885. * @returns Input value from DeviceInputSystem
  49886. */
  49887. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  49888. }
  49889. /**
  49890. * Class to keep track of devices
  49891. */
  49892. export class DeviceSourceManager implements IDisposable {
  49893. /**
  49894. * Observable to be triggered when before a device is connected
  49895. */
  49896. readonly onBeforeDeviceConnectedObservable: Observable<{
  49897. deviceType: DeviceType;
  49898. deviceSlot: number;
  49899. }>;
  49900. /**
  49901. * Observable to be triggered when before a device is disconnected
  49902. */
  49903. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  49904. deviceType: DeviceType;
  49905. deviceSlot: number;
  49906. }>;
  49907. /**
  49908. * Observable to be triggered when after a device is connected
  49909. */
  49910. readonly onAfterDeviceConnectedObservable: Observable<{
  49911. deviceType: DeviceType;
  49912. deviceSlot: number;
  49913. }>;
  49914. /**
  49915. * Observable to be triggered when after a device is disconnected
  49916. */
  49917. readonly onAfterDeviceDisconnectedObservable: Observable<{
  49918. deviceType: DeviceType;
  49919. deviceSlot: number;
  49920. }>;
  49921. private readonly _devices;
  49922. private readonly _firstDevice;
  49923. private readonly _deviceInputSystem;
  49924. /**
  49925. * Default Constructor
  49926. * @param engine engine to pull input element from
  49927. */
  49928. constructor(engine: Engine);
  49929. /**
  49930. * Gets a DeviceSource, given a type and slot
  49931. * @param deviceType Enum specifying device type
  49932. * @param deviceSlot "Slot" or index that device is referenced in
  49933. * @returns DeviceSource object
  49934. */
  49935. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  49936. /**
  49937. * Gets an array of DeviceSource objects for a given device type
  49938. * @param deviceType Enum specifying device type
  49939. * @returns Array of DeviceSource objects
  49940. */
  49941. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  49942. /**
  49943. * Dispose of DeviceInputSystem and other parts
  49944. */
  49945. dispose(): void;
  49946. /**
  49947. * Function to add device name to device list
  49948. * @param deviceType Enum specifying device type
  49949. * @param deviceSlot "Slot" or index that device is referenced in
  49950. */
  49951. private _addDevice;
  49952. /**
  49953. * Function to remove device name to device list
  49954. * @param deviceType Enum specifying device type
  49955. * @param deviceSlot "Slot" or index that device is referenced in
  49956. */
  49957. private _removeDevice;
  49958. /**
  49959. * Updates array storing first connected device of each type
  49960. * @param type Type of Device
  49961. */
  49962. private _updateFirstDevices;
  49963. }
  49964. }
  49965. declare module BABYLON {
  49966. /**
  49967. * Options to create the null engine
  49968. */
  49969. export class NullEngineOptions {
  49970. /**
  49971. * Render width (Default: 512)
  49972. */
  49973. renderWidth: number;
  49974. /**
  49975. * Render height (Default: 256)
  49976. */
  49977. renderHeight: number;
  49978. /**
  49979. * Texture size (Default: 512)
  49980. */
  49981. textureSize: number;
  49982. /**
  49983. * If delta time between frames should be constant
  49984. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49985. */
  49986. deterministicLockstep: boolean;
  49987. /**
  49988. * Maximum about of steps between frames (Default: 4)
  49989. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  49990. */
  49991. lockstepMaxSteps: number;
  49992. }
  49993. /**
  49994. * The null engine class provides support for headless version of babylon.js.
  49995. * This can be used in server side scenario or for testing purposes
  49996. */
  49997. export class NullEngine extends Engine {
  49998. private _options;
  49999. /**
  50000. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50001. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50002. * @returns true if engine is in deterministic lock step mode
  50003. */
  50004. isDeterministicLockStep(): boolean;
  50005. /**
  50006. * Gets the max steps when engine is running in deterministic lock step
  50007. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50008. * @returns the max steps
  50009. */
  50010. getLockstepMaxSteps(): number;
  50011. /**
  50012. * Gets the current hardware scaling level.
  50013. * By default the hardware scaling level is computed from the window device ratio.
  50014. * 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.
  50015. * @returns a number indicating the current hardware scaling level
  50016. */
  50017. getHardwareScalingLevel(): number;
  50018. constructor(options?: NullEngineOptions);
  50019. /**
  50020. * Creates a vertex buffer
  50021. * @param vertices the data for the vertex buffer
  50022. * @returns the new WebGL static buffer
  50023. */
  50024. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50025. /**
  50026. * Creates a new index buffer
  50027. * @param indices defines the content of the index buffer
  50028. * @param updatable defines if the index buffer must be updatable
  50029. * @returns a new webGL buffer
  50030. */
  50031. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50032. /**
  50033. * Clear the current render buffer or the current render target (if any is set up)
  50034. * @param color defines the color to use
  50035. * @param backBuffer defines if the back buffer must be cleared
  50036. * @param depth defines if the depth buffer must be cleared
  50037. * @param stencil defines if the stencil buffer must be cleared
  50038. */
  50039. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50040. /**
  50041. * Gets the current render width
  50042. * @param useScreen defines if screen size must be used (or the current render target if any)
  50043. * @returns a number defining the current render width
  50044. */
  50045. getRenderWidth(useScreen?: boolean): number;
  50046. /**
  50047. * Gets the current render height
  50048. * @param useScreen defines if screen size must be used (or the current render target if any)
  50049. * @returns a number defining the current render height
  50050. */
  50051. getRenderHeight(useScreen?: boolean): number;
  50052. /**
  50053. * Set the WebGL's viewport
  50054. * @param viewport defines the viewport element to be used
  50055. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50056. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50057. */
  50058. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50059. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50060. /**
  50061. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50062. * @param pipelineContext defines the pipeline context to use
  50063. * @param uniformsNames defines the list of uniform names
  50064. * @returns an array of webGL uniform locations
  50065. */
  50066. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50067. /**
  50068. * Gets the lsit of active attributes for a given webGL program
  50069. * @param pipelineContext defines the pipeline context to use
  50070. * @param attributesNames defines the list of attribute names to get
  50071. * @returns an array of indices indicating the offset of each attribute
  50072. */
  50073. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50074. /**
  50075. * Binds an effect to the webGL context
  50076. * @param effect defines the effect to bind
  50077. */
  50078. bindSamplers(effect: Effect): void;
  50079. /**
  50080. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50081. * @param effect defines the effect to activate
  50082. */
  50083. enableEffect(effect: Effect): void;
  50084. /**
  50085. * Set various states to the webGL context
  50086. * @param culling defines backface culling state
  50087. * @param zOffset defines the value to apply to zOffset (0 by default)
  50088. * @param force defines if states must be applied even if cache is up to date
  50089. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50090. */
  50091. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50092. /**
  50093. * Set the value of an uniform to an array of int32
  50094. * @param uniform defines the webGL uniform location where to store the value
  50095. * @param array defines the array of int32 to store
  50096. */
  50097. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50098. /**
  50099. * Set the value of an uniform to an array of int32 (stored as vec2)
  50100. * @param uniform defines the webGL uniform location where to store the value
  50101. * @param array defines the array of int32 to store
  50102. */
  50103. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50104. /**
  50105. * Set the value of an uniform to an array of int32 (stored as vec3)
  50106. * @param uniform defines the webGL uniform location where to store the value
  50107. * @param array defines the array of int32 to store
  50108. */
  50109. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50110. /**
  50111. * Set the value of an uniform to an array of int32 (stored as vec4)
  50112. * @param uniform defines the webGL uniform location where to store the value
  50113. * @param array defines the array of int32 to store
  50114. */
  50115. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50116. /**
  50117. * Set the value of an uniform to an array of float32
  50118. * @param uniform defines the webGL uniform location where to store the value
  50119. * @param array defines the array of float32 to store
  50120. */
  50121. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50122. /**
  50123. * Set the value of an uniform to an array of float32 (stored as vec2)
  50124. * @param uniform defines the webGL uniform location where to store the value
  50125. * @param array defines the array of float32 to store
  50126. */
  50127. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50128. /**
  50129. * Set the value of an uniform to an array of float32 (stored as vec3)
  50130. * @param uniform defines the webGL uniform location where to store the value
  50131. * @param array defines the array of float32 to store
  50132. */
  50133. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50134. /**
  50135. * Set the value of an uniform to an array of float32 (stored as vec4)
  50136. * @param uniform defines the webGL uniform location where to store the value
  50137. * @param array defines the array of float32 to store
  50138. */
  50139. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50140. /**
  50141. * Set the value of an uniform to an array of number
  50142. * @param uniform defines the webGL uniform location where to store the value
  50143. * @param array defines the array of number to store
  50144. */
  50145. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50146. /**
  50147. * Set the value of an uniform to an array of number (stored as vec2)
  50148. * @param uniform defines the webGL uniform location where to store the value
  50149. * @param array defines the array of number to store
  50150. */
  50151. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50152. /**
  50153. * Set the value of an uniform to an array of number (stored as vec3)
  50154. * @param uniform defines the webGL uniform location where to store the value
  50155. * @param array defines the array of number to store
  50156. */
  50157. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50158. /**
  50159. * Set the value of an uniform to an array of number (stored as vec4)
  50160. * @param uniform defines the webGL uniform location where to store the value
  50161. * @param array defines the array of number to store
  50162. */
  50163. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50164. /**
  50165. * Set the value of an uniform to an array of float32 (stored as matrices)
  50166. * @param uniform defines the webGL uniform location where to store the value
  50167. * @param matrices defines the array of float32 to store
  50168. */
  50169. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50170. /**
  50171. * Set the value of an uniform to a matrix (3x3)
  50172. * @param uniform defines the webGL uniform location where to store the value
  50173. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50174. */
  50175. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50176. /**
  50177. * Set the value of an uniform to a matrix (2x2)
  50178. * @param uniform defines the webGL uniform location where to store the value
  50179. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50180. */
  50181. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50182. /**
  50183. * Set the value of an uniform to a number (float)
  50184. * @param uniform defines the webGL uniform location where to store the value
  50185. * @param value defines the float number to store
  50186. */
  50187. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50188. /**
  50189. * Set the value of an uniform to a vec2
  50190. * @param uniform defines the webGL uniform location where to store the value
  50191. * @param x defines the 1st component of the value
  50192. * @param y defines the 2nd component of the value
  50193. */
  50194. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50195. /**
  50196. * Set the value of an uniform to a vec3
  50197. * @param uniform defines the webGL uniform location where to store the value
  50198. * @param x defines the 1st component of the value
  50199. * @param y defines the 2nd component of the value
  50200. * @param z defines the 3rd component of the value
  50201. */
  50202. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50203. /**
  50204. * Set the value of an uniform to a boolean
  50205. * @param uniform defines the webGL uniform location where to store the value
  50206. * @param bool defines the boolean to store
  50207. */
  50208. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50209. /**
  50210. * Set the value of an uniform to a vec4
  50211. * @param uniform defines the webGL uniform location where to store the value
  50212. * @param x defines the 1st component of the value
  50213. * @param y defines the 2nd component of the value
  50214. * @param z defines the 3rd component of the value
  50215. * @param w defines the 4th component of the value
  50216. */
  50217. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50218. /**
  50219. * Sets the current alpha mode
  50220. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50221. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50222. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50223. */
  50224. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50225. /**
  50226. * Bind webGl buffers directly to the webGL context
  50227. * @param vertexBuffers defines the vertex buffer to bind
  50228. * @param indexBuffer defines the index buffer to bind
  50229. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50230. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50231. * @param effect defines the effect associated with the vertex buffer
  50232. */
  50233. bindBuffers(vertexBuffers: {
  50234. [key: string]: VertexBuffer;
  50235. }, indexBuffer: DataBuffer, effect: Effect): void;
  50236. /**
  50237. * Force the entire cache to be cleared
  50238. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50239. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50240. */
  50241. wipeCaches(bruteForce?: boolean): void;
  50242. /**
  50243. * Send a draw order
  50244. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50245. * @param indexStart defines the starting index
  50246. * @param indexCount defines the number of index to draw
  50247. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50248. */
  50249. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50250. /**
  50251. * Draw a list of indexed primitives
  50252. * @param fillMode defines the primitive to use
  50253. * @param indexStart defines the starting index
  50254. * @param indexCount defines the number of index to draw
  50255. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50256. */
  50257. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50258. /**
  50259. * Draw a list of unindexed primitives
  50260. * @param fillMode defines the primitive to use
  50261. * @param verticesStart defines the index of first vertex to draw
  50262. * @param verticesCount defines the count of vertices to draw
  50263. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50264. */
  50265. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50266. /** @hidden */
  50267. _createTexture(): WebGLTexture;
  50268. /** @hidden */
  50269. _releaseTexture(texture: InternalTexture): void;
  50270. /**
  50271. * Usually called from Texture.ts.
  50272. * Passed information to create a WebGLTexture
  50273. * @param urlArg defines a value which contains one of the following:
  50274. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50275. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50276. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50277. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50278. * @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)
  50279. * @param scene needed for loading to the correct scene
  50280. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50281. * @param onLoad optional callback to be called upon successful completion
  50282. * @param onError optional callback to be called upon failure
  50283. * @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
  50284. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50285. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50286. * @param forcedExtension defines the extension to use to pick the right loader
  50287. * @param mimeType defines an optional mime type
  50288. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50289. */
  50290. 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;
  50291. /**
  50292. * Creates a new render target texture
  50293. * @param size defines the size of the texture
  50294. * @param options defines the options used to create the texture
  50295. * @returns a new render target texture stored in an InternalTexture
  50296. */
  50297. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50298. /**
  50299. * Update the sampling mode of a given texture
  50300. * @param samplingMode defines the required sampling mode
  50301. * @param texture defines the texture to update
  50302. */
  50303. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50304. /**
  50305. * Binds the frame buffer to the specified texture.
  50306. * @param texture The texture to render to or null for the default canvas
  50307. * @param faceIndex The face of the texture to render to in case of cube texture
  50308. * @param requiredWidth The width of the target to render to
  50309. * @param requiredHeight The height of the target to render to
  50310. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50311. * @param lodLevel defines le lod level to bind to the frame buffer
  50312. */
  50313. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50314. /**
  50315. * Unbind the current render target texture from the webGL context
  50316. * @param texture defines the render target texture to unbind
  50317. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50318. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50319. */
  50320. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50321. /**
  50322. * Creates a dynamic vertex buffer
  50323. * @param vertices the data for the dynamic vertex buffer
  50324. * @returns the new WebGL dynamic buffer
  50325. */
  50326. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50327. /**
  50328. * Update the content of a dynamic texture
  50329. * @param texture defines the texture to update
  50330. * @param canvas defines the canvas containing the source
  50331. * @param invertY defines if data must be stored with Y axis inverted
  50332. * @param premulAlpha defines if alpha is stored as premultiplied
  50333. * @param format defines the format of the data
  50334. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50335. */
  50336. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50337. /**
  50338. * Gets a boolean indicating if all created effects are ready
  50339. * @returns true if all effects are ready
  50340. */
  50341. areAllEffectsReady(): boolean;
  50342. /**
  50343. * @hidden
  50344. * Get the current error code of the webGL context
  50345. * @returns the error code
  50346. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50347. */
  50348. getError(): number;
  50349. /** @hidden */
  50350. _getUnpackAlignement(): number;
  50351. /** @hidden */
  50352. _unpackFlipY(value: boolean): void;
  50353. /**
  50354. * Update a dynamic index buffer
  50355. * @param indexBuffer defines the target index buffer
  50356. * @param indices defines the data to update
  50357. * @param offset defines the offset in the target index buffer where update should start
  50358. */
  50359. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50360. /**
  50361. * Updates a dynamic vertex buffer.
  50362. * @param vertexBuffer the vertex buffer to update
  50363. * @param vertices the data used to update the vertex buffer
  50364. * @param byteOffset the byte offset of the data (optional)
  50365. * @param byteLength the byte length of the data (optional)
  50366. */
  50367. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50368. /** @hidden */
  50369. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50370. /** @hidden */
  50371. _bindTexture(channel: number, texture: InternalTexture): void;
  50372. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50373. /**
  50374. * 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
  50375. */
  50376. releaseEffects(): void;
  50377. displayLoadingUI(): void;
  50378. hideLoadingUI(): void;
  50379. /** @hidden */
  50380. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50381. /** @hidden */
  50382. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50383. /** @hidden */
  50384. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50385. /** @hidden */
  50386. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50387. }
  50388. }
  50389. declare module BABYLON {
  50390. /**
  50391. * @hidden
  50392. **/
  50393. export class _TimeToken {
  50394. _startTimeQuery: Nullable<WebGLQuery>;
  50395. _endTimeQuery: Nullable<WebGLQuery>;
  50396. _timeElapsedQuery: Nullable<WebGLQuery>;
  50397. _timeElapsedQueryEnded: boolean;
  50398. }
  50399. }
  50400. declare module BABYLON {
  50401. /** @hidden */
  50402. export class _OcclusionDataStorage {
  50403. /** @hidden */
  50404. occlusionInternalRetryCounter: number;
  50405. /** @hidden */
  50406. isOcclusionQueryInProgress: boolean;
  50407. /** @hidden */
  50408. isOccluded: boolean;
  50409. /** @hidden */
  50410. occlusionRetryCount: number;
  50411. /** @hidden */
  50412. occlusionType: number;
  50413. /** @hidden */
  50414. occlusionQueryAlgorithmType: number;
  50415. }
  50416. interface Engine {
  50417. /**
  50418. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50419. * @return the new query
  50420. */
  50421. createQuery(): WebGLQuery;
  50422. /**
  50423. * Delete and release a webGL query
  50424. * @param query defines the query to delete
  50425. * @return the current engine
  50426. */
  50427. deleteQuery(query: WebGLQuery): Engine;
  50428. /**
  50429. * Check if a given query has resolved and got its value
  50430. * @param query defines the query to check
  50431. * @returns true if the query got its value
  50432. */
  50433. isQueryResultAvailable(query: WebGLQuery): boolean;
  50434. /**
  50435. * Gets the value of a given query
  50436. * @param query defines the query to check
  50437. * @returns the value of the query
  50438. */
  50439. getQueryResult(query: WebGLQuery): number;
  50440. /**
  50441. * Initiates an occlusion query
  50442. * @param algorithmType defines the algorithm to use
  50443. * @param query defines the query to use
  50444. * @returns the current engine
  50445. * @see http://doc.babylonjs.com/features/occlusionquery
  50446. */
  50447. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50448. /**
  50449. * Ends an occlusion query
  50450. * @see http://doc.babylonjs.com/features/occlusionquery
  50451. * @param algorithmType defines the algorithm to use
  50452. * @returns the current engine
  50453. */
  50454. endOcclusionQuery(algorithmType: number): Engine;
  50455. /**
  50456. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50457. * Please note that only one query can be issued at a time
  50458. * @returns a time token used to track the time span
  50459. */
  50460. startTimeQuery(): Nullable<_TimeToken>;
  50461. /**
  50462. * Ends a time query
  50463. * @param token defines the token used to measure the time span
  50464. * @returns the time spent (in ns)
  50465. */
  50466. endTimeQuery(token: _TimeToken): int;
  50467. /** @hidden */
  50468. _currentNonTimestampToken: Nullable<_TimeToken>;
  50469. /** @hidden */
  50470. _createTimeQuery(): WebGLQuery;
  50471. /** @hidden */
  50472. _deleteTimeQuery(query: WebGLQuery): void;
  50473. /** @hidden */
  50474. _getGlAlgorithmType(algorithmType: number): number;
  50475. /** @hidden */
  50476. _getTimeQueryResult(query: WebGLQuery): any;
  50477. /** @hidden */
  50478. _getTimeQueryAvailability(query: WebGLQuery): any;
  50479. }
  50480. interface AbstractMesh {
  50481. /**
  50482. * Backing filed
  50483. * @hidden
  50484. */
  50485. __occlusionDataStorage: _OcclusionDataStorage;
  50486. /**
  50487. * Access property
  50488. * @hidden
  50489. */
  50490. _occlusionDataStorage: _OcclusionDataStorage;
  50491. /**
  50492. * 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.
  50493. * The default value is -1 which means don't break the query and wait till the result
  50494. * @see http://doc.babylonjs.com/features/occlusionquery
  50495. */
  50496. occlusionRetryCount: number;
  50497. /**
  50498. * 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:
  50499. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50500. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50501. * * 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.
  50502. * @see http://doc.babylonjs.com/features/occlusionquery
  50503. */
  50504. occlusionType: number;
  50505. /**
  50506. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50507. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50508. * * 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.
  50509. * @see http://doc.babylonjs.com/features/occlusionquery
  50510. */
  50511. occlusionQueryAlgorithmType: number;
  50512. /**
  50513. * 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
  50514. * @see http://doc.babylonjs.com/features/occlusionquery
  50515. */
  50516. isOccluded: boolean;
  50517. /**
  50518. * Flag to check the progress status of the query
  50519. * @see http://doc.babylonjs.com/features/occlusionquery
  50520. */
  50521. isOcclusionQueryInProgress: boolean;
  50522. }
  50523. }
  50524. declare module BABYLON {
  50525. /** @hidden */
  50526. export var _forceTransformFeedbackToBundle: boolean;
  50527. interface Engine {
  50528. /**
  50529. * Creates a webGL transform feedback object
  50530. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50531. * @returns the webGL transform feedback object
  50532. */
  50533. createTransformFeedback(): WebGLTransformFeedback;
  50534. /**
  50535. * Delete a webGL transform feedback object
  50536. * @param value defines the webGL transform feedback object to delete
  50537. */
  50538. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50539. /**
  50540. * Bind a webGL transform feedback object to the webgl context
  50541. * @param value defines the webGL transform feedback object to bind
  50542. */
  50543. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50544. /**
  50545. * Begins a transform feedback operation
  50546. * @param usePoints defines if points or triangles must be used
  50547. */
  50548. beginTransformFeedback(usePoints: boolean): void;
  50549. /**
  50550. * Ends a transform feedback operation
  50551. */
  50552. endTransformFeedback(): void;
  50553. /**
  50554. * Specify the varyings to use with transform feedback
  50555. * @param program defines the associated webGL program
  50556. * @param value defines the list of strings representing the varying names
  50557. */
  50558. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50559. /**
  50560. * Bind a webGL buffer for a transform feedback operation
  50561. * @param value defines the webGL buffer to bind
  50562. */
  50563. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50564. }
  50565. }
  50566. declare module BABYLON {
  50567. /**
  50568. * Creation options of the multi render target texture.
  50569. */
  50570. export interface IMultiRenderTargetOptions {
  50571. /**
  50572. * Define if the texture needs to create mip maps after render.
  50573. */
  50574. generateMipMaps?: boolean;
  50575. /**
  50576. * Define the types of all the draw buffers we want to create
  50577. */
  50578. types?: number[];
  50579. /**
  50580. * Define the sampling modes of all the draw buffers we want to create
  50581. */
  50582. samplingModes?: number[];
  50583. /**
  50584. * Define if a depth buffer is required
  50585. */
  50586. generateDepthBuffer?: boolean;
  50587. /**
  50588. * Define if a stencil buffer is required
  50589. */
  50590. generateStencilBuffer?: boolean;
  50591. /**
  50592. * Define if a depth texture is required instead of a depth buffer
  50593. */
  50594. generateDepthTexture?: boolean;
  50595. /**
  50596. * Define the number of desired draw buffers
  50597. */
  50598. textureCount?: number;
  50599. /**
  50600. * Define if aspect ratio should be adapted to the texture or stay the scene one
  50601. */
  50602. doNotChangeAspectRatio?: boolean;
  50603. /**
  50604. * Define the default type of the buffers we are creating
  50605. */
  50606. defaultType?: number;
  50607. }
  50608. /**
  50609. * A multi render target, like a render target provides the ability to render to a texture.
  50610. * Unlike the render target, it can render to several draw buffers in one draw.
  50611. * This is specially interesting in deferred rendering or for any effects requiring more than
  50612. * just one color from a single pass.
  50613. */
  50614. export class MultiRenderTarget extends RenderTargetTexture {
  50615. private _internalTextures;
  50616. private _textures;
  50617. private _multiRenderTargetOptions;
  50618. /**
  50619. * Get if draw buffers are currently supported by the used hardware and browser.
  50620. */
  50621. get isSupported(): boolean;
  50622. /**
  50623. * Get the list of textures generated by the multi render target.
  50624. */
  50625. get textures(): Texture[];
  50626. /**
  50627. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  50628. */
  50629. get depthTexture(): Texture;
  50630. /**
  50631. * Set the wrapping mode on U of all the textures we are rendering to.
  50632. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50633. */
  50634. set wrapU(wrap: number);
  50635. /**
  50636. * Set the wrapping mode on V of all the textures we are rendering to.
  50637. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  50638. */
  50639. set wrapV(wrap: number);
  50640. /**
  50641. * Instantiate a new multi render target texture.
  50642. * A multi render target, like a render target provides the ability to render to a texture.
  50643. * Unlike the render target, it can render to several draw buffers in one draw.
  50644. * This is specially interesting in deferred rendering or for any effects requiring more than
  50645. * just one color from a single pass.
  50646. * @param name Define the name of the texture
  50647. * @param size Define the size of the buffers to render to
  50648. * @param count Define the number of target we are rendering into
  50649. * @param scene Define the scene the texture belongs to
  50650. * @param options Define the options used to create the multi render target
  50651. */
  50652. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  50653. /** @hidden */
  50654. _rebuild(): void;
  50655. private _createInternalTextures;
  50656. private _createTextures;
  50657. /**
  50658. * Define the number of samples used if MSAA is enabled.
  50659. */
  50660. get samples(): number;
  50661. set samples(value: number);
  50662. /**
  50663. * Resize all the textures in the multi render target.
  50664. * Be carrefull as it will recreate all the data in the new texture.
  50665. * @param size Define the new size
  50666. */
  50667. resize(size: any): void;
  50668. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  50669. /**
  50670. * Dispose the render targets and their associated resources
  50671. */
  50672. dispose(): void;
  50673. /**
  50674. * Release all the underlying texture used as draw buffers.
  50675. */
  50676. releaseInternalTextures(): void;
  50677. }
  50678. }
  50679. declare module BABYLON {
  50680. interface ThinEngine {
  50681. /**
  50682. * Unbind a list of render target textures from the webGL context
  50683. * This is used only when drawBuffer extension or webGL2 are active
  50684. * @param textures defines the render target textures to unbind
  50685. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50686. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50687. */
  50688. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  50689. /**
  50690. * Create a multi render target texture
  50691. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  50692. * @param size defines the size of the texture
  50693. * @param options defines the creation options
  50694. * @returns the cube texture as an InternalTexture
  50695. */
  50696. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  50697. /**
  50698. * Update the sample count for a given multiple render target texture
  50699. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  50700. * @param textures defines the textures to update
  50701. * @param samples defines the sample count to set
  50702. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  50703. */
  50704. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  50705. }
  50706. }
  50707. declare module BABYLON {
  50708. /**
  50709. * Class used to define an additional view for the engine
  50710. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50711. */
  50712. export class EngineView {
  50713. /** Defines the canvas where to render the view */
  50714. target: HTMLCanvasElement;
  50715. /** Defines an optional camera used to render the view (will use active camera else) */
  50716. camera?: Camera;
  50717. }
  50718. interface Engine {
  50719. /**
  50720. * Gets or sets the HTML element to use for attaching events
  50721. */
  50722. inputElement: Nullable<HTMLElement>;
  50723. /**
  50724. * Gets the current engine view
  50725. * @see https://doc.babylonjs.com/how_to/multi_canvases
  50726. */
  50727. activeView: Nullable<EngineView>;
  50728. /** Gets or sets the list of views */
  50729. views: EngineView[];
  50730. /**
  50731. * Register a new child canvas
  50732. * @param canvas defines the canvas to register
  50733. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  50734. * @returns the associated view
  50735. */
  50736. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  50737. /**
  50738. * Remove a registered child canvas
  50739. * @param canvas defines the canvas to remove
  50740. * @returns the current engine
  50741. */
  50742. unRegisterView(canvas: HTMLCanvasElement): Engine;
  50743. }
  50744. }
  50745. declare module BABYLON {
  50746. interface Engine {
  50747. /** @hidden */
  50748. _excludedCompressedTextures: string[];
  50749. /** @hidden */
  50750. _textureFormatInUse: string;
  50751. /**
  50752. * Gets the list of texture formats supported
  50753. */
  50754. readonly texturesSupported: Array<string>;
  50755. /**
  50756. * Gets the texture format in use
  50757. */
  50758. readonly textureFormatInUse: Nullable<string>;
  50759. /**
  50760. * Set the compressed texture extensions or file names to skip.
  50761. *
  50762. * @param skippedFiles defines the list of those texture files you want to skip
  50763. * Example: [".dds", ".env", "myfile.png"]
  50764. */
  50765. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  50766. /**
  50767. * Set the compressed texture format to use, based on the formats you have, and the formats
  50768. * supported by the hardware / browser.
  50769. *
  50770. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  50771. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  50772. * to API arguments needed to compressed textures. This puts the burden on the container
  50773. * generator to house the arcane code for determining these for current & future formats.
  50774. *
  50775. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50776. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50777. *
  50778. * Note: The result of this call is not taken into account when a texture is base64.
  50779. *
  50780. * @param formatsAvailable defines the list of those format families you have created
  50781. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  50782. *
  50783. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  50784. * @returns The extension selected.
  50785. */
  50786. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  50787. }
  50788. }
  50789. declare module BABYLON {
  50790. /**
  50791. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  50792. */
  50793. export interface CubeMapInfo {
  50794. /**
  50795. * The pixel array for the front face.
  50796. * This is stored in format, left to right, up to down format.
  50797. */
  50798. front: Nullable<ArrayBufferView>;
  50799. /**
  50800. * The pixel array for the back face.
  50801. * This is stored in format, left to right, up to down format.
  50802. */
  50803. back: Nullable<ArrayBufferView>;
  50804. /**
  50805. * The pixel array for the left face.
  50806. * This is stored in format, left to right, up to down format.
  50807. */
  50808. left: Nullable<ArrayBufferView>;
  50809. /**
  50810. * The pixel array for the right face.
  50811. * This is stored in format, left to right, up to down format.
  50812. */
  50813. right: Nullable<ArrayBufferView>;
  50814. /**
  50815. * The pixel array for the up face.
  50816. * This is stored in format, left to right, up to down format.
  50817. */
  50818. up: Nullable<ArrayBufferView>;
  50819. /**
  50820. * The pixel array for the down face.
  50821. * This is stored in format, left to right, up to down format.
  50822. */
  50823. down: Nullable<ArrayBufferView>;
  50824. /**
  50825. * The size of the cubemap stored.
  50826. *
  50827. * Each faces will be size * size pixels.
  50828. */
  50829. size: number;
  50830. /**
  50831. * The format of the texture.
  50832. *
  50833. * RGBA, RGB.
  50834. */
  50835. format: number;
  50836. /**
  50837. * The type of the texture data.
  50838. *
  50839. * UNSIGNED_INT, FLOAT.
  50840. */
  50841. type: number;
  50842. /**
  50843. * Specifies whether the texture is in gamma space.
  50844. */
  50845. gammaSpace: boolean;
  50846. }
  50847. /**
  50848. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  50849. */
  50850. export class PanoramaToCubeMapTools {
  50851. private static FACE_LEFT;
  50852. private static FACE_RIGHT;
  50853. private static FACE_FRONT;
  50854. private static FACE_BACK;
  50855. private static FACE_DOWN;
  50856. private static FACE_UP;
  50857. /**
  50858. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  50859. *
  50860. * @param float32Array The source data.
  50861. * @param inputWidth The width of the input panorama.
  50862. * @param inputHeight The height of the input panorama.
  50863. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  50864. * @return The cubemap data
  50865. */
  50866. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  50867. private static CreateCubemapTexture;
  50868. private static CalcProjectionSpherical;
  50869. }
  50870. }
  50871. declare module BABYLON {
  50872. /**
  50873. * Helper class dealing with the extraction of spherical polynomial dataArray
  50874. * from a cube map.
  50875. */
  50876. export class CubeMapToSphericalPolynomialTools {
  50877. private static FileFaces;
  50878. /**
  50879. * Converts a texture to the according Spherical Polynomial data.
  50880. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50881. *
  50882. * @param texture The texture to extract the information from.
  50883. * @return The Spherical Polynomial data.
  50884. */
  50885. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  50886. /**
  50887. * Converts a cubemap to the according Spherical Polynomial data.
  50888. * This extracts the first 3 orders only as they are the only one used in the lighting.
  50889. *
  50890. * @param cubeInfo The Cube map to extract the information from.
  50891. * @return The Spherical Polynomial data.
  50892. */
  50893. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  50894. }
  50895. }
  50896. declare module BABYLON {
  50897. interface BaseTexture {
  50898. /**
  50899. * Get the polynomial representation of the texture data.
  50900. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  50901. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  50902. */
  50903. sphericalPolynomial: Nullable<SphericalPolynomial>;
  50904. }
  50905. }
  50906. declare module BABYLON {
  50907. /** @hidden */
  50908. export var rgbdEncodePixelShader: {
  50909. name: string;
  50910. shader: string;
  50911. };
  50912. }
  50913. declare module BABYLON {
  50914. /** @hidden */
  50915. export var rgbdDecodePixelShader: {
  50916. name: string;
  50917. shader: string;
  50918. };
  50919. }
  50920. declare module BABYLON {
  50921. /**
  50922. * Raw texture data and descriptor sufficient for WebGL texture upload
  50923. */
  50924. export interface EnvironmentTextureInfo {
  50925. /**
  50926. * Version of the environment map
  50927. */
  50928. version: number;
  50929. /**
  50930. * Width of image
  50931. */
  50932. width: number;
  50933. /**
  50934. * Irradiance information stored in the file.
  50935. */
  50936. irradiance: any;
  50937. /**
  50938. * Specular information stored in the file.
  50939. */
  50940. specular: any;
  50941. }
  50942. /**
  50943. * Defines One Image in the file. It requires only the position in the file
  50944. * as well as the length.
  50945. */
  50946. interface BufferImageData {
  50947. /**
  50948. * Length of the image data.
  50949. */
  50950. length: number;
  50951. /**
  50952. * Position of the data from the null terminator delimiting the end of the JSON.
  50953. */
  50954. position: number;
  50955. }
  50956. /**
  50957. * Defines the specular data enclosed in the file.
  50958. * This corresponds to the version 1 of the data.
  50959. */
  50960. export interface EnvironmentTextureSpecularInfoV1 {
  50961. /**
  50962. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  50963. */
  50964. specularDataPosition?: number;
  50965. /**
  50966. * This contains all the images data needed to reconstruct the cubemap.
  50967. */
  50968. mipmaps: Array<BufferImageData>;
  50969. /**
  50970. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  50971. */
  50972. lodGenerationScale: number;
  50973. }
  50974. /**
  50975. * Sets of helpers addressing the serialization and deserialization of environment texture
  50976. * stored in a BabylonJS env file.
  50977. * Those files are usually stored as .env files.
  50978. */
  50979. export class EnvironmentTextureTools {
  50980. /**
  50981. * Magic number identifying the env file.
  50982. */
  50983. private static _MagicBytes;
  50984. /**
  50985. * Gets the environment info from an env file.
  50986. * @param data The array buffer containing the .env bytes.
  50987. * @returns the environment file info (the json header) if successfully parsed.
  50988. */
  50989. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  50990. /**
  50991. * Creates an environment texture from a loaded cube texture.
  50992. * @param texture defines the cube texture to convert in env file
  50993. * @return a promise containing the environment data if succesfull.
  50994. */
  50995. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  50996. /**
  50997. * Creates a JSON representation of the spherical data.
  50998. * @param texture defines the texture containing the polynomials
  50999. * @return the JSON representation of the spherical info
  51000. */
  51001. private static _CreateEnvTextureIrradiance;
  51002. /**
  51003. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51004. * @param data the image data
  51005. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51006. * @return the views described by info providing access to the underlying buffer
  51007. */
  51008. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51009. /**
  51010. * Uploads the texture info contained in the env file to the GPU.
  51011. * @param texture defines the internal texture to upload to
  51012. * @param data defines the data to load
  51013. * @param info defines the texture info retrieved through the GetEnvInfo method
  51014. * @returns a promise
  51015. */
  51016. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51017. private static _OnImageReadyAsync;
  51018. /**
  51019. * Uploads the levels of image data to the GPU.
  51020. * @param texture defines the internal texture to upload to
  51021. * @param imageData defines the array buffer views of image data [mipmap][face]
  51022. * @returns a promise
  51023. */
  51024. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51025. /**
  51026. * Uploads spherical polynomials information to the texture.
  51027. * @param texture defines the texture we are trying to upload the information to
  51028. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51029. */
  51030. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51031. /** @hidden */
  51032. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51033. }
  51034. }
  51035. declare module BABYLON {
  51036. /** @hidden */
  51037. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  51038. private _genericAttributeLocation;
  51039. private _varyingLocationCount;
  51040. private _varyingLocationMap;
  51041. private _replacements;
  51042. private _textureCount;
  51043. private _uniforms;
  51044. lineProcessor(line: string): string;
  51045. attributeProcessor(attribute: string): string;
  51046. varyingProcessor(varying: string, isFragment: boolean): string;
  51047. uniformProcessor(uniform: string): string;
  51048. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51049. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51050. }
  51051. }
  51052. declare module BABYLON {
  51053. /**
  51054. * Class used to inline functions in shader code
  51055. */
  51056. export class ShaderCodeInliner {
  51057. private static readonly _RegexpFindFunctionNameAndType;
  51058. private _sourceCode;
  51059. private _functionDescr;
  51060. private _numMaxIterations;
  51061. /** Gets or sets the token used to mark the functions to inline */
  51062. inlineToken: string;
  51063. /** Gets or sets the debug mode */
  51064. debug: boolean;
  51065. /** Gets the code after the inlining process */
  51066. get code(): string;
  51067. /**
  51068. * Initializes the inliner
  51069. * @param sourceCode shader code source to inline
  51070. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51071. */
  51072. constructor(sourceCode: string, numMaxIterations?: number);
  51073. /**
  51074. * Start the processing of the shader code
  51075. */
  51076. processCode(): void;
  51077. private _collectFunctions;
  51078. private _processInlining;
  51079. private _extractBetweenMarkers;
  51080. private _skipWhitespaces;
  51081. private _removeComments;
  51082. private _replaceFunctionCallsByCode;
  51083. private _findBackward;
  51084. private _escapeRegExp;
  51085. private _replaceNames;
  51086. }
  51087. }
  51088. declare module BABYLON {
  51089. /**
  51090. * Container for accessors for natively-stored mesh data buffers.
  51091. */
  51092. class NativeDataBuffer extends DataBuffer {
  51093. /**
  51094. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51095. */
  51096. nativeIndexBuffer?: any;
  51097. /**
  51098. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51099. */
  51100. nativeVertexBuffer?: any;
  51101. }
  51102. /** @hidden */
  51103. class NativeTexture extends InternalTexture {
  51104. getInternalTexture(): InternalTexture;
  51105. getViewCount(): number;
  51106. }
  51107. /** @hidden */
  51108. export class NativeEngine extends Engine {
  51109. private readonly _native;
  51110. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51111. private readonly INVALID_HANDLE;
  51112. getHardwareScalingLevel(): number;
  51113. constructor();
  51114. dispose(): void;
  51115. /**
  51116. * Can be used to override the current requestAnimationFrame requester.
  51117. * @hidden
  51118. */
  51119. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51120. /**
  51121. * Override default engine behavior.
  51122. * @param color
  51123. * @param backBuffer
  51124. * @param depth
  51125. * @param stencil
  51126. */
  51127. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51128. /**
  51129. * Gets host document
  51130. * @returns the host document object
  51131. */
  51132. getHostDocument(): Nullable<Document>;
  51133. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51134. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51135. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51136. recordVertexArrayObject(vertexBuffers: {
  51137. [key: string]: VertexBuffer;
  51138. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51139. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51140. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51141. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51142. /**
  51143. * Draw a list of indexed primitives
  51144. * @param fillMode defines the primitive to use
  51145. * @param indexStart defines the starting index
  51146. * @param indexCount defines the number of index to draw
  51147. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51148. */
  51149. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51150. /**
  51151. * Draw a list of unindexed primitives
  51152. * @param fillMode defines the primitive to use
  51153. * @param verticesStart defines the index of first vertex to draw
  51154. * @param verticesCount defines the count of vertices to draw
  51155. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51156. */
  51157. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51158. createPipelineContext(): IPipelineContext;
  51159. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51160. /** @hidden */
  51161. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51162. /** @hidden */
  51163. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51164. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51165. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51166. protected _setProgram(program: WebGLProgram): void;
  51167. _releaseEffect(effect: Effect): void;
  51168. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51169. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51170. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51171. bindSamplers(effect: Effect): void;
  51172. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51173. getRenderWidth(useScreen?: boolean): number;
  51174. getRenderHeight(useScreen?: boolean): number;
  51175. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51176. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51177. /**
  51178. * Set the z offset to apply to current rendering
  51179. * @param value defines the offset to apply
  51180. */
  51181. setZOffset(value: number): void;
  51182. /**
  51183. * Gets the current value of the zOffset
  51184. * @returns the current zOffset state
  51185. */
  51186. getZOffset(): number;
  51187. /**
  51188. * Enable or disable depth buffering
  51189. * @param enable defines the state to set
  51190. */
  51191. setDepthBuffer(enable: boolean): void;
  51192. /**
  51193. * Gets a boolean indicating if depth writing is enabled
  51194. * @returns the current depth writing state
  51195. */
  51196. getDepthWrite(): boolean;
  51197. /**
  51198. * Enable or disable depth writing
  51199. * @param enable defines the state to set
  51200. */
  51201. setDepthWrite(enable: boolean): void;
  51202. /**
  51203. * Enable or disable color writing
  51204. * @param enable defines the state to set
  51205. */
  51206. setColorWrite(enable: boolean): void;
  51207. /**
  51208. * Gets a boolean indicating if color writing is enabled
  51209. * @returns the current color writing state
  51210. */
  51211. getColorWrite(): boolean;
  51212. /**
  51213. * Sets alpha constants used by some alpha blending modes
  51214. * @param r defines the red component
  51215. * @param g defines the green component
  51216. * @param b defines the blue component
  51217. * @param a defines the alpha component
  51218. */
  51219. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51220. /**
  51221. * Sets the current alpha mode
  51222. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51223. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51224. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51225. */
  51226. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51227. /**
  51228. * Gets the current alpha mode
  51229. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51230. * @returns the current alpha mode
  51231. */
  51232. getAlphaMode(): number;
  51233. setInt(uniform: WebGLUniformLocation, int: number): void;
  51234. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51235. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51236. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51237. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51238. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51239. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51240. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51241. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51242. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51243. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51244. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51245. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51246. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51247. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51248. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51249. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51250. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51251. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51252. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51253. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51254. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51255. wipeCaches(bruteForce?: boolean): void;
  51256. _createTexture(): WebGLTexture;
  51257. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51258. /**
  51259. * Usually called from Texture.ts.
  51260. * Passed information to create a WebGLTexture
  51261. * @param url defines a value which contains one of the following:
  51262. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51263. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51264. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51265. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51266. * @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)
  51267. * @param scene needed for loading to the correct scene
  51268. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51269. * @param onLoad optional callback to be called upon successful completion
  51270. * @param onError optional callback to be called upon failure
  51271. * @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
  51272. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51273. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51274. * @param forcedExtension defines the extension to use to pick the right loader
  51275. * @param mimeType defines an optional mime type
  51276. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51277. */
  51278. 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;
  51279. /**
  51280. * Creates a cube texture
  51281. * @param rootUrl defines the url where the files to load is located
  51282. * @param scene defines the current scene
  51283. * @param files defines the list of files to load (1 per face)
  51284. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51285. * @param onLoad defines an optional callback raised when the texture is loaded
  51286. * @param onError defines an optional callback raised if there is an issue to load the texture
  51287. * @param format defines the format of the data
  51288. * @param forcedExtension defines the extension to use to pick the right loader
  51289. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51290. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51291. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51292. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51293. * @returns the cube texture as an InternalTexture
  51294. */
  51295. 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;
  51296. private _getSamplingFilter;
  51297. private static _GetNativeTextureFormat;
  51298. createRenderTargetTexture(size: number | {
  51299. width: number;
  51300. height: number;
  51301. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51302. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51303. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51304. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51305. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51306. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51307. /**
  51308. * Updates a dynamic vertex buffer.
  51309. * @param vertexBuffer the vertex buffer to update
  51310. * @param data the data used to update the vertex buffer
  51311. * @param byteOffset the byte offset of the data (optional)
  51312. * @param byteLength the byte length of the data (optional)
  51313. */
  51314. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51315. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51316. private _updateAnisotropicLevel;
  51317. private _getAddressMode;
  51318. /** @hidden */
  51319. _bindTexture(channel: number, texture: InternalTexture): void;
  51320. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51321. releaseEffects(): void;
  51322. /** @hidden */
  51323. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51324. /** @hidden */
  51325. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51326. /** @hidden */
  51327. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51328. /** @hidden */
  51329. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51330. }
  51331. }
  51332. declare module BABYLON {
  51333. /**
  51334. * Gather the list of clipboard event types as constants.
  51335. */
  51336. export class ClipboardEventTypes {
  51337. /**
  51338. * The clipboard event is fired when a copy command is active (pressed).
  51339. */
  51340. static readonly COPY: number;
  51341. /**
  51342. * The clipboard event is fired when a cut command is active (pressed).
  51343. */
  51344. static readonly CUT: number;
  51345. /**
  51346. * The clipboard event is fired when a paste command is active (pressed).
  51347. */
  51348. static readonly PASTE: number;
  51349. }
  51350. /**
  51351. * This class is used to store clipboard related info for the onClipboardObservable event.
  51352. */
  51353. export class ClipboardInfo {
  51354. /**
  51355. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51356. */
  51357. type: number;
  51358. /**
  51359. * Defines the related dom event
  51360. */
  51361. event: ClipboardEvent;
  51362. /**
  51363. *Creates an instance of ClipboardInfo.
  51364. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51365. * @param event Defines the related dom event
  51366. */
  51367. constructor(
  51368. /**
  51369. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51370. */
  51371. type: number,
  51372. /**
  51373. * Defines the related dom event
  51374. */
  51375. event: ClipboardEvent);
  51376. /**
  51377. * Get the clipboard event's type from the keycode.
  51378. * @param keyCode Defines the keyCode for the current keyboard event.
  51379. * @return {number}
  51380. */
  51381. static GetTypeFromCharacter(keyCode: number): number;
  51382. }
  51383. }
  51384. declare module BABYLON {
  51385. /**
  51386. * Google Daydream controller
  51387. */
  51388. export class DaydreamController extends WebVRController {
  51389. /**
  51390. * Base Url for the controller model.
  51391. */
  51392. static MODEL_BASE_URL: string;
  51393. /**
  51394. * File name for the controller model.
  51395. */
  51396. static MODEL_FILENAME: string;
  51397. /**
  51398. * Gamepad Id prefix used to identify Daydream Controller.
  51399. */
  51400. static readonly GAMEPAD_ID_PREFIX: string;
  51401. /**
  51402. * Creates a new DaydreamController from a gamepad
  51403. * @param vrGamepad the gamepad that the controller should be created from
  51404. */
  51405. constructor(vrGamepad: any);
  51406. /**
  51407. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51408. * @param scene scene in which to add meshes
  51409. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51410. */
  51411. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51412. /**
  51413. * Called once for each button that changed state since the last frame
  51414. * @param buttonIdx Which button index changed
  51415. * @param state New state of the button
  51416. * @param changes Which properties on the state changed since last frame
  51417. */
  51418. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51419. }
  51420. }
  51421. declare module BABYLON {
  51422. /**
  51423. * Gear VR Controller
  51424. */
  51425. export class GearVRController extends WebVRController {
  51426. /**
  51427. * Base Url for the controller model.
  51428. */
  51429. static MODEL_BASE_URL: string;
  51430. /**
  51431. * File name for the controller model.
  51432. */
  51433. static MODEL_FILENAME: string;
  51434. /**
  51435. * Gamepad Id prefix used to identify this controller.
  51436. */
  51437. static readonly GAMEPAD_ID_PREFIX: string;
  51438. private readonly _buttonIndexToObservableNameMap;
  51439. /**
  51440. * Creates a new GearVRController from a gamepad
  51441. * @param vrGamepad the gamepad that the controller should be created from
  51442. */
  51443. constructor(vrGamepad: any);
  51444. /**
  51445. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51446. * @param scene scene in which to add meshes
  51447. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51448. */
  51449. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51450. /**
  51451. * Called once for each button that changed state since the last frame
  51452. * @param buttonIdx Which button index changed
  51453. * @param state New state of the button
  51454. * @param changes Which properties on the state changed since last frame
  51455. */
  51456. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51457. }
  51458. }
  51459. declare module BABYLON {
  51460. /**
  51461. * Generic Controller
  51462. */
  51463. export class GenericController extends WebVRController {
  51464. /**
  51465. * Base Url for the controller model.
  51466. */
  51467. static readonly MODEL_BASE_URL: string;
  51468. /**
  51469. * File name for the controller model.
  51470. */
  51471. static readonly MODEL_FILENAME: string;
  51472. /**
  51473. * Creates a new GenericController from a gamepad
  51474. * @param vrGamepad the gamepad that the controller should be created from
  51475. */
  51476. constructor(vrGamepad: any);
  51477. /**
  51478. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51479. * @param scene scene in which to add meshes
  51480. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51481. */
  51482. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51483. /**
  51484. * Called once for each button that changed state since the last frame
  51485. * @param buttonIdx Which button index changed
  51486. * @param state New state of the button
  51487. * @param changes Which properties on the state changed since last frame
  51488. */
  51489. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51490. }
  51491. }
  51492. declare module BABYLON {
  51493. /**
  51494. * Oculus Touch Controller
  51495. */
  51496. export class OculusTouchController extends WebVRController {
  51497. /**
  51498. * Base Url for the controller model.
  51499. */
  51500. static MODEL_BASE_URL: string;
  51501. /**
  51502. * File name for the left controller model.
  51503. */
  51504. static MODEL_LEFT_FILENAME: string;
  51505. /**
  51506. * File name for the right controller model.
  51507. */
  51508. static MODEL_RIGHT_FILENAME: string;
  51509. /**
  51510. * Base Url for the Quest controller model.
  51511. */
  51512. static QUEST_MODEL_BASE_URL: string;
  51513. /**
  51514. * @hidden
  51515. * If the controllers are running on a device that needs the updated Quest controller models
  51516. */
  51517. static _IsQuest: boolean;
  51518. /**
  51519. * Fired when the secondary trigger on this controller is modified
  51520. */
  51521. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51522. /**
  51523. * Fired when the thumb rest on this controller is modified
  51524. */
  51525. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51526. /**
  51527. * Creates a new OculusTouchController from a gamepad
  51528. * @param vrGamepad the gamepad that the controller should be created from
  51529. */
  51530. constructor(vrGamepad: any);
  51531. /**
  51532. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51533. * @param scene scene in which to add meshes
  51534. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51535. */
  51536. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51537. /**
  51538. * Fired when the A button on this controller is modified
  51539. */
  51540. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51541. /**
  51542. * Fired when the B button on this controller is modified
  51543. */
  51544. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51545. /**
  51546. * Fired when the X button on this controller is modified
  51547. */
  51548. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51549. /**
  51550. * Fired when the Y button on this controller is modified
  51551. */
  51552. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51553. /**
  51554. * Called once for each button that changed state since the last frame
  51555. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51556. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51557. * 2) secondary trigger (same)
  51558. * 3) A (right) X (left), touch, pressed = value
  51559. * 4) B / Y
  51560. * 5) thumb rest
  51561. * @param buttonIdx Which button index changed
  51562. * @param state New state of the button
  51563. * @param changes Which properties on the state changed since last frame
  51564. */
  51565. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51566. }
  51567. }
  51568. declare module BABYLON {
  51569. /**
  51570. * Vive Controller
  51571. */
  51572. export class ViveController extends WebVRController {
  51573. /**
  51574. * Base Url for the controller model.
  51575. */
  51576. static MODEL_BASE_URL: string;
  51577. /**
  51578. * File name for the controller model.
  51579. */
  51580. static MODEL_FILENAME: string;
  51581. /**
  51582. * Creates a new ViveController from a gamepad
  51583. * @param vrGamepad the gamepad that the controller should be created from
  51584. */
  51585. constructor(vrGamepad: any);
  51586. /**
  51587. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51588. * @param scene scene in which to add meshes
  51589. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51590. */
  51591. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51592. /**
  51593. * Fired when the left button on this controller is modified
  51594. */
  51595. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51596. /**
  51597. * Fired when the right button on this controller is modified
  51598. */
  51599. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51600. /**
  51601. * Fired when the menu button on this controller is modified
  51602. */
  51603. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51604. /**
  51605. * Called once for each button that changed state since the last frame
  51606. * Vive mapping:
  51607. * 0: touchpad
  51608. * 1: trigger
  51609. * 2: left AND right buttons
  51610. * 3: menu button
  51611. * @param buttonIdx Which button index changed
  51612. * @param state New state of the button
  51613. * @param changes Which properties on the state changed since last frame
  51614. */
  51615. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51616. }
  51617. }
  51618. declare module BABYLON {
  51619. /**
  51620. * Defines the WindowsMotionController object that the state of the windows motion controller
  51621. */
  51622. export class WindowsMotionController extends WebVRController {
  51623. /**
  51624. * The base url used to load the left and right controller models
  51625. */
  51626. static MODEL_BASE_URL: string;
  51627. /**
  51628. * The name of the left controller model file
  51629. */
  51630. static MODEL_LEFT_FILENAME: string;
  51631. /**
  51632. * The name of the right controller model file
  51633. */
  51634. static MODEL_RIGHT_FILENAME: string;
  51635. /**
  51636. * The controller name prefix for this controller type
  51637. */
  51638. static readonly GAMEPAD_ID_PREFIX: string;
  51639. /**
  51640. * The controller id pattern for this controller type
  51641. */
  51642. private static readonly GAMEPAD_ID_PATTERN;
  51643. private _loadedMeshInfo;
  51644. protected readonly _mapping: {
  51645. buttons: string[];
  51646. buttonMeshNames: {
  51647. trigger: string;
  51648. menu: string;
  51649. grip: string;
  51650. thumbstick: string;
  51651. trackpad: string;
  51652. };
  51653. buttonObservableNames: {
  51654. trigger: string;
  51655. menu: string;
  51656. grip: string;
  51657. thumbstick: string;
  51658. trackpad: string;
  51659. };
  51660. axisMeshNames: string[];
  51661. pointingPoseMeshName: string;
  51662. };
  51663. /**
  51664. * Fired when the trackpad on this controller is clicked
  51665. */
  51666. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51667. /**
  51668. * Fired when the trackpad on this controller is modified
  51669. */
  51670. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51671. /**
  51672. * The current x and y values of this controller's trackpad
  51673. */
  51674. trackpad: StickValues;
  51675. /**
  51676. * Creates a new WindowsMotionController from a gamepad
  51677. * @param vrGamepad the gamepad that the controller should be created from
  51678. */
  51679. constructor(vrGamepad: any);
  51680. /**
  51681. * Fired when the trigger on this controller is modified
  51682. */
  51683. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51684. /**
  51685. * Fired when the menu button on this controller is modified
  51686. */
  51687. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51688. /**
  51689. * Fired when the grip button on this controller is modified
  51690. */
  51691. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51692. /**
  51693. * Fired when the thumbstick button on this controller is modified
  51694. */
  51695. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51696. /**
  51697. * Fired when the touchpad button on this controller is modified
  51698. */
  51699. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51700. /**
  51701. * Fired when the touchpad values on this controller are modified
  51702. */
  51703. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  51704. protected _updateTrackpad(): void;
  51705. /**
  51706. * Called once per frame by the engine.
  51707. */
  51708. update(): void;
  51709. /**
  51710. * Called once for each button that changed state since the last frame
  51711. * @param buttonIdx Which button index changed
  51712. * @param state New state of the button
  51713. * @param changes Which properties on the state changed since last frame
  51714. */
  51715. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51716. /**
  51717. * Moves the buttons on the controller mesh based on their current state
  51718. * @param buttonName the name of the button to move
  51719. * @param buttonValue the value of the button which determines the buttons new position
  51720. */
  51721. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  51722. /**
  51723. * Moves the axis on the controller mesh based on its current state
  51724. * @param axis the index of the axis
  51725. * @param axisValue the value of the axis which determines the meshes new position
  51726. * @hidden
  51727. */
  51728. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  51729. /**
  51730. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51731. * @param scene scene in which to add meshes
  51732. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51733. */
  51734. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  51735. /**
  51736. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  51737. * can be transformed by button presses and axes values, based on this._mapping.
  51738. *
  51739. * @param scene scene in which the meshes exist
  51740. * @param meshes list of meshes that make up the controller model to process
  51741. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  51742. */
  51743. private processModel;
  51744. private createMeshInfo;
  51745. /**
  51746. * Gets the ray of the controller in the direction the controller is pointing
  51747. * @param length the length the resulting ray should be
  51748. * @returns a ray in the direction the controller is pointing
  51749. */
  51750. getForwardRay(length?: number): Ray;
  51751. /**
  51752. * Disposes of the controller
  51753. */
  51754. dispose(): void;
  51755. }
  51756. /**
  51757. * This class represents a new windows motion controller in XR.
  51758. */
  51759. export class XRWindowsMotionController extends WindowsMotionController {
  51760. /**
  51761. * Changing the original WIndowsMotionController mapping to fir the new mapping
  51762. */
  51763. protected readonly _mapping: {
  51764. buttons: string[];
  51765. buttonMeshNames: {
  51766. trigger: string;
  51767. menu: string;
  51768. grip: string;
  51769. thumbstick: string;
  51770. trackpad: string;
  51771. };
  51772. buttonObservableNames: {
  51773. trigger: string;
  51774. menu: string;
  51775. grip: string;
  51776. thumbstick: string;
  51777. trackpad: string;
  51778. };
  51779. axisMeshNames: string[];
  51780. pointingPoseMeshName: string;
  51781. };
  51782. /**
  51783. * Construct a new XR-Based windows motion controller
  51784. *
  51785. * @param gamepadInfo the gamepad object from the browser
  51786. */
  51787. constructor(gamepadInfo: any);
  51788. /**
  51789. * holds the thumbstick values (X,Y)
  51790. */
  51791. thumbstickValues: StickValues;
  51792. /**
  51793. * Fired when the thumbstick on this controller is clicked
  51794. */
  51795. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  51796. /**
  51797. * Fired when the thumbstick on this controller is modified
  51798. */
  51799. onThumbstickValuesChangedObservable: Observable<StickValues>;
  51800. /**
  51801. * Fired when the touchpad button on this controller is modified
  51802. */
  51803. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  51804. /**
  51805. * Fired when the touchpad values on this controller are modified
  51806. */
  51807. onTrackpadValuesChangedObservable: Observable<StickValues>;
  51808. /**
  51809. * Fired when the thumbstick button on this controller is modified
  51810. * here to prevent breaking changes
  51811. */
  51812. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51813. /**
  51814. * updating the thumbstick(!) and not the trackpad.
  51815. * This is named this way due to the difference between WebVR and XR and to avoid
  51816. * changing the parent class.
  51817. */
  51818. protected _updateTrackpad(): void;
  51819. /**
  51820. * Disposes the class with joy
  51821. */
  51822. dispose(): void;
  51823. }
  51824. }
  51825. declare module BABYLON {
  51826. /**
  51827. * Class containing static functions to help procedurally build meshes
  51828. */
  51829. export class PolyhedronBuilder {
  51830. /**
  51831. * Creates a polyhedron mesh
  51832. * * 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
  51833. * * The parameter `size` (positive float, default 1) sets the polygon size
  51834. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51835. * * 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`
  51836. * * 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
  51837. * * 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)`)
  51838. * * 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
  51839. * * 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
  51840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51841. * * 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
  51842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51843. * @param name defines the name of the mesh
  51844. * @param options defines the options used to create the mesh
  51845. * @param scene defines the hosting scene
  51846. * @returns the polyhedron mesh
  51847. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51848. */
  51849. static CreatePolyhedron(name: string, options: {
  51850. type?: number;
  51851. size?: number;
  51852. sizeX?: number;
  51853. sizeY?: number;
  51854. sizeZ?: number;
  51855. custom?: any;
  51856. faceUV?: Vector4[];
  51857. faceColors?: Color4[];
  51858. flat?: boolean;
  51859. updatable?: boolean;
  51860. sideOrientation?: number;
  51861. frontUVs?: Vector4;
  51862. backUVs?: Vector4;
  51863. }, scene?: Nullable<Scene>): Mesh;
  51864. }
  51865. }
  51866. declare module BABYLON {
  51867. /**
  51868. * Gizmo that enables scaling a mesh along 3 axis
  51869. */
  51870. export class ScaleGizmo extends Gizmo {
  51871. /**
  51872. * Internal gizmo used for interactions on the x axis
  51873. */
  51874. xGizmo: AxisScaleGizmo;
  51875. /**
  51876. * Internal gizmo used for interactions on the y axis
  51877. */
  51878. yGizmo: AxisScaleGizmo;
  51879. /**
  51880. * Internal gizmo used for interactions on the z axis
  51881. */
  51882. zGizmo: AxisScaleGizmo;
  51883. /**
  51884. * Internal gizmo used to scale all axis equally
  51885. */
  51886. uniformScaleGizmo: AxisScaleGizmo;
  51887. private _meshAttached;
  51888. private _updateGizmoRotationToMatchAttachedMesh;
  51889. private _snapDistance;
  51890. private _scaleRatio;
  51891. private _uniformScalingMesh;
  51892. private _octahedron;
  51893. private _sensitivity;
  51894. /** Fires an event when any of it's sub gizmos are dragged */
  51895. onDragStartObservable: Observable<unknown>;
  51896. /** Fires an event when any of it's sub gizmos are released from dragging */
  51897. onDragEndObservable: Observable<unknown>;
  51898. get attachedMesh(): Nullable<AbstractMesh>;
  51899. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51900. /**
  51901. * Creates a ScaleGizmo
  51902. * @param gizmoLayer The utility layer the gizmo will be added to
  51903. */
  51904. constructor(gizmoLayer?: UtilityLayerRenderer);
  51905. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51906. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51907. /**
  51908. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51909. */
  51910. set snapDistance(value: number);
  51911. get snapDistance(): number;
  51912. /**
  51913. * Ratio for the scale of the gizmo (Default: 1)
  51914. */
  51915. set scaleRatio(value: number);
  51916. get scaleRatio(): number;
  51917. /**
  51918. * Sensitivity factor for dragging (Default: 1)
  51919. */
  51920. set sensitivity(value: number);
  51921. get sensitivity(): number;
  51922. /**
  51923. * Disposes of the gizmo
  51924. */
  51925. dispose(): void;
  51926. }
  51927. }
  51928. declare module BABYLON {
  51929. /**
  51930. * Single axis scale gizmo
  51931. */
  51932. export class AxisScaleGizmo extends Gizmo {
  51933. /**
  51934. * Drag behavior responsible for the gizmos dragging interactions
  51935. */
  51936. dragBehavior: PointerDragBehavior;
  51937. private _pointerObserver;
  51938. /**
  51939. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51940. */
  51941. snapDistance: number;
  51942. /**
  51943. * Event that fires each time the gizmo snaps to a new location.
  51944. * * snapDistance is the the change in distance
  51945. */
  51946. onSnapObservable: Observable<{
  51947. snapDistance: number;
  51948. }>;
  51949. /**
  51950. * If the scaling operation should be done on all axis (default: false)
  51951. */
  51952. uniformScaling: boolean;
  51953. /**
  51954. * Custom sensitivity value for the drag strength
  51955. */
  51956. sensitivity: number;
  51957. private _isEnabled;
  51958. private _parent;
  51959. private _arrow;
  51960. private _coloredMaterial;
  51961. private _hoverMaterial;
  51962. /**
  51963. * Creates an AxisScaleGizmo
  51964. * @param gizmoLayer The utility layer the gizmo will be added to
  51965. * @param dragAxis The axis which the gizmo will be able to scale on
  51966. * @param color The color of the gizmo
  51967. */
  51968. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  51969. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51970. /**
  51971. * If the gizmo is enabled
  51972. */
  51973. set isEnabled(value: boolean);
  51974. get isEnabled(): boolean;
  51975. /**
  51976. * Disposes of the gizmo
  51977. */
  51978. dispose(): void;
  51979. /**
  51980. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51981. * @param mesh The mesh to replace the default mesh of the gizmo
  51982. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  51983. */
  51984. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  51985. }
  51986. }
  51987. declare module BABYLON {
  51988. /**
  51989. * Bounding box gizmo
  51990. */
  51991. export class BoundingBoxGizmo extends Gizmo {
  51992. private _lineBoundingBox;
  51993. private _rotateSpheresParent;
  51994. private _scaleBoxesParent;
  51995. private _boundingDimensions;
  51996. private _renderObserver;
  51997. private _pointerObserver;
  51998. private _scaleDragSpeed;
  51999. private _tmpQuaternion;
  52000. private _tmpVector;
  52001. private _tmpRotationMatrix;
  52002. /**
  52003. * 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)
  52004. */
  52005. ignoreChildren: boolean;
  52006. /**
  52007. * 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)
  52008. */
  52009. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52010. /**
  52011. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52012. */
  52013. rotationSphereSize: number;
  52014. /**
  52015. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52016. */
  52017. scaleBoxSize: number;
  52018. /**
  52019. * 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)
  52020. */
  52021. fixedDragMeshScreenSize: boolean;
  52022. /**
  52023. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52024. */
  52025. fixedDragMeshScreenSizeDistanceFactor: number;
  52026. /**
  52027. * Fired when a rotation sphere or scale box is dragged
  52028. */
  52029. onDragStartObservable: Observable<{}>;
  52030. /**
  52031. * Fired when a scale box is dragged
  52032. */
  52033. onScaleBoxDragObservable: Observable<{}>;
  52034. /**
  52035. * Fired when a scale box drag is ended
  52036. */
  52037. onScaleBoxDragEndObservable: Observable<{}>;
  52038. /**
  52039. * Fired when a rotation sphere is dragged
  52040. */
  52041. onRotationSphereDragObservable: Observable<{}>;
  52042. /**
  52043. * Fired when a rotation sphere drag is ended
  52044. */
  52045. onRotationSphereDragEndObservable: Observable<{}>;
  52046. /**
  52047. * 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)
  52048. */
  52049. scalePivot: Nullable<Vector3>;
  52050. /**
  52051. * Mesh used as a pivot to rotate the attached mesh
  52052. */
  52053. private _anchorMesh;
  52054. private _existingMeshScale;
  52055. private _dragMesh;
  52056. private pointerDragBehavior;
  52057. private coloredMaterial;
  52058. private hoverColoredMaterial;
  52059. /**
  52060. * Sets the color of the bounding box gizmo
  52061. * @param color the color to set
  52062. */
  52063. setColor(color: Color3): void;
  52064. /**
  52065. * Creates an BoundingBoxGizmo
  52066. * @param gizmoLayer The utility layer the gizmo will be added to
  52067. * @param color The color of the gizmo
  52068. */
  52069. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52070. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52071. private _selectNode;
  52072. /**
  52073. * Updates the bounding box information for the Gizmo
  52074. */
  52075. updateBoundingBox(): void;
  52076. private _updateRotationSpheres;
  52077. private _updateScaleBoxes;
  52078. /**
  52079. * Enables rotation on the specified axis and disables rotation on the others
  52080. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52081. */
  52082. setEnabledRotationAxis(axis: string): void;
  52083. /**
  52084. * Enables/disables scaling
  52085. * @param enable if scaling should be enabled
  52086. * @param homogeneousScaling defines if scaling should only be homogeneous
  52087. */
  52088. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52089. private _updateDummy;
  52090. /**
  52091. * Enables a pointer drag behavior on the bounding box of the gizmo
  52092. */
  52093. enableDragBehavior(): void;
  52094. /**
  52095. * Disposes of the gizmo
  52096. */
  52097. dispose(): void;
  52098. /**
  52099. * 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)
  52100. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52101. * @returns the bounding box mesh with the passed in mesh as a child
  52102. */
  52103. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52104. /**
  52105. * CustomMeshes are not supported by this gizmo
  52106. * @param mesh The mesh to replace the default mesh of the gizmo
  52107. */
  52108. setCustomMesh(mesh: Mesh): void;
  52109. }
  52110. }
  52111. declare module BABYLON {
  52112. /**
  52113. * Single plane rotation gizmo
  52114. */
  52115. export class PlaneRotationGizmo extends Gizmo {
  52116. /**
  52117. * Drag behavior responsible for the gizmos dragging interactions
  52118. */
  52119. dragBehavior: PointerDragBehavior;
  52120. private _pointerObserver;
  52121. /**
  52122. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52123. */
  52124. snapDistance: number;
  52125. /**
  52126. * Event that fires each time the gizmo snaps to a new location.
  52127. * * snapDistance is the the change in distance
  52128. */
  52129. onSnapObservable: Observable<{
  52130. snapDistance: number;
  52131. }>;
  52132. private _isEnabled;
  52133. private _parent;
  52134. /**
  52135. * Creates a PlaneRotationGizmo
  52136. * @param gizmoLayer The utility layer the gizmo will be added to
  52137. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52138. * @param color The color of the gizmo
  52139. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52140. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52141. */
  52142. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52143. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52144. /**
  52145. * If the gizmo is enabled
  52146. */
  52147. set isEnabled(value: boolean);
  52148. get isEnabled(): boolean;
  52149. /**
  52150. * Disposes of the gizmo
  52151. */
  52152. dispose(): void;
  52153. }
  52154. }
  52155. declare module BABYLON {
  52156. /**
  52157. * Gizmo that enables rotating a mesh along 3 axis
  52158. */
  52159. export class RotationGizmo extends Gizmo {
  52160. /**
  52161. * Internal gizmo used for interactions on the x axis
  52162. */
  52163. xGizmo: PlaneRotationGizmo;
  52164. /**
  52165. * Internal gizmo used for interactions on the y axis
  52166. */
  52167. yGizmo: PlaneRotationGizmo;
  52168. /**
  52169. * Internal gizmo used for interactions on the z axis
  52170. */
  52171. zGizmo: PlaneRotationGizmo;
  52172. /** Fires an event when any of it's sub gizmos are dragged */
  52173. onDragStartObservable: Observable<unknown>;
  52174. /** Fires an event when any of it's sub gizmos are released from dragging */
  52175. onDragEndObservable: Observable<unknown>;
  52176. private _meshAttached;
  52177. get attachedMesh(): Nullable<AbstractMesh>;
  52178. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52179. /**
  52180. * Creates a RotationGizmo
  52181. * @param gizmoLayer The utility layer the gizmo will be added to
  52182. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52183. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52184. */
  52185. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52186. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52187. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52188. /**
  52189. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52190. */
  52191. set snapDistance(value: number);
  52192. get snapDistance(): number;
  52193. /**
  52194. * Ratio for the scale of the gizmo (Default: 1)
  52195. */
  52196. set scaleRatio(value: number);
  52197. get scaleRatio(): number;
  52198. /**
  52199. * Disposes of the gizmo
  52200. */
  52201. dispose(): void;
  52202. /**
  52203. * CustomMeshes are not supported by this gizmo
  52204. * @param mesh The mesh to replace the default mesh of the gizmo
  52205. */
  52206. setCustomMesh(mesh: Mesh): void;
  52207. }
  52208. }
  52209. declare module BABYLON {
  52210. /**
  52211. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52212. */
  52213. export class GizmoManager implements IDisposable {
  52214. private scene;
  52215. /**
  52216. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52217. */
  52218. gizmos: {
  52219. positionGizmo: Nullable<PositionGizmo>;
  52220. rotationGizmo: Nullable<RotationGizmo>;
  52221. scaleGizmo: Nullable<ScaleGizmo>;
  52222. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52223. };
  52224. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52225. clearGizmoOnEmptyPointerEvent: boolean;
  52226. /** Fires an event when the manager is attached to a mesh */
  52227. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52228. private _gizmosEnabled;
  52229. private _pointerObserver;
  52230. private _attachedMesh;
  52231. private _boundingBoxColor;
  52232. private _defaultUtilityLayer;
  52233. private _defaultKeepDepthUtilityLayer;
  52234. /**
  52235. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52236. */
  52237. boundingBoxDragBehavior: SixDofDragBehavior;
  52238. /**
  52239. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52240. */
  52241. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52242. /**
  52243. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52244. */
  52245. usePointerToAttachGizmos: boolean;
  52246. /**
  52247. * Utility layer that the bounding box gizmo belongs to
  52248. */
  52249. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52250. /**
  52251. * Utility layer that all gizmos besides bounding box belong to
  52252. */
  52253. get utilityLayer(): UtilityLayerRenderer;
  52254. /**
  52255. * Instatiates a gizmo manager
  52256. * @param scene the scene to overlay the gizmos on top of
  52257. */
  52258. constructor(scene: Scene);
  52259. /**
  52260. * Attaches a set of gizmos to the specified mesh
  52261. * @param mesh The mesh the gizmo's should be attached to
  52262. */
  52263. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52264. /**
  52265. * If the position gizmo is enabled
  52266. */
  52267. set positionGizmoEnabled(value: boolean);
  52268. get positionGizmoEnabled(): boolean;
  52269. /**
  52270. * If the rotation gizmo is enabled
  52271. */
  52272. set rotationGizmoEnabled(value: boolean);
  52273. get rotationGizmoEnabled(): boolean;
  52274. /**
  52275. * If the scale gizmo is enabled
  52276. */
  52277. set scaleGizmoEnabled(value: boolean);
  52278. get scaleGizmoEnabled(): boolean;
  52279. /**
  52280. * If the boundingBox gizmo is enabled
  52281. */
  52282. set boundingBoxGizmoEnabled(value: boolean);
  52283. get boundingBoxGizmoEnabled(): boolean;
  52284. /**
  52285. * Disposes of the gizmo manager
  52286. */
  52287. dispose(): void;
  52288. }
  52289. }
  52290. declare module BABYLON {
  52291. /**
  52292. * A directional light is defined by a direction (what a surprise!).
  52293. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52294. * 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.
  52295. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52296. */
  52297. export class DirectionalLight extends ShadowLight {
  52298. private _shadowFrustumSize;
  52299. /**
  52300. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52301. */
  52302. get shadowFrustumSize(): number;
  52303. /**
  52304. * Specifies a fix frustum size for the shadow generation.
  52305. */
  52306. set shadowFrustumSize(value: number);
  52307. private _shadowOrthoScale;
  52308. /**
  52309. * Gets the shadow projection scale against the optimal computed one.
  52310. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52311. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52312. */
  52313. get shadowOrthoScale(): number;
  52314. /**
  52315. * Sets the shadow projection scale against the optimal computed one.
  52316. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52317. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52318. */
  52319. set shadowOrthoScale(value: number);
  52320. /**
  52321. * Automatically compute the projection matrix to best fit (including all the casters)
  52322. * on each frame.
  52323. */
  52324. autoUpdateExtends: boolean;
  52325. /**
  52326. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52327. * on each frame. autoUpdateExtends must be set to true for this to work
  52328. */
  52329. autoCalcShadowZBounds: boolean;
  52330. private _orthoLeft;
  52331. private _orthoRight;
  52332. private _orthoTop;
  52333. private _orthoBottom;
  52334. /**
  52335. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52336. * The directional light is emitted from everywhere in the given direction.
  52337. * It can cast shadows.
  52338. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52339. * @param name The friendly name of the light
  52340. * @param direction The direction of the light
  52341. * @param scene The scene the light belongs to
  52342. */
  52343. constructor(name: string, direction: Vector3, scene: Scene);
  52344. /**
  52345. * Returns the string "DirectionalLight".
  52346. * @return The class name
  52347. */
  52348. getClassName(): string;
  52349. /**
  52350. * Returns the integer 1.
  52351. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52352. */
  52353. getTypeID(): number;
  52354. /**
  52355. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52356. * Returns the DirectionalLight Shadow projection matrix.
  52357. */
  52358. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52359. /**
  52360. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52361. * Returns the DirectionalLight Shadow projection matrix.
  52362. */
  52363. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52364. /**
  52365. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52366. * Returns the DirectionalLight Shadow projection matrix.
  52367. */
  52368. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52369. protected _buildUniformLayout(): void;
  52370. /**
  52371. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52372. * @param effect The effect to update
  52373. * @param lightIndex The index of the light in the effect to update
  52374. * @returns The directional light
  52375. */
  52376. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52377. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52378. /**
  52379. * Gets the minZ used for shadow according to both the scene and the light.
  52380. *
  52381. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52382. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52383. * @param activeCamera The camera we are returning the min for
  52384. * @returns the depth min z
  52385. */
  52386. getDepthMinZ(activeCamera: Camera): number;
  52387. /**
  52388. * Gets the maxZ used for shadow according to both the scene and the light.
  52389. *
  52390. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52391. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52392. * @param activeCamera The camera we are returning the max for
  52393. * @returns the depth max z
  52394. */
  52395. getDepthMaxZ(activeCamera: Camera): number;
  52396. /**
  52397. * Prepares the list of defines specific to the light type.
  52398. * @param defines the list of defines
  52399. * @param lightIndex defines the index of the light for the effect
  52400. */
  52401. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52402. }
  52403. }
  52404. declare module BABYLON {
  52405. /**
  52406. * Class containing static functions to help procedurally build meshes
  52407. */
  52408. export class HemisphereBuilder {
  52409. /**
  52410. * Creates a hemisphere mesh
  52411. * @param name defines the name of the mesh
  52412. * @param options defines the options used to create the mesh
  52413. * @param scene defines the hosting scene
  52414. * @returns the hemisphere mesh
  52415. */
  52416. static CreateHemisphere(name: string, options: {
  52417. segments?: number;
  52418. diameter?: number;
  52419. sideOrientation?: number;
  52420. }, scene: any): Mesh;
  52421. }
  52422. }
  52423. declare module BABYLON {
  52424. /**
  52425. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52426. * These values define a cone of light starting from the position, emitting toward the direction.
  52427. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52428. * and the exponent defines the speed of the decay of the light with distance (reach).
  52429. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52430. */
  52431. export class SpotLight extends ShadowLight {
  52432. private _angle;
  52433. private _innerAngle;
  52434. private _cosHalfAngle;
  52435. private _lightAngleScale;
  52436. private _lightAngleOffset;
  52437. /**
  52438. * Gets the cone angle of the spot light in Radians.
  52439. */
  52440. get angle(): number;
  52441. /**
  52442. * Sets the cone angle of the spot light in Radians.
  52443. */
  52444. set angle(value: number);
  52445. /**
  52446. * Only used in gltf falloff mode, this defines the angle where
  52447. * the directional falloff will start before cutting at angle which could be seen
  52448. * as outer angle.
  52449. */
  52450. get innerAngle(): number;
  52451. /**
  52452. * Only used in gltf falloff mode, this defines the angle where
  52453. * the directional falloff will start before cutting at angle which could be seen
  52454. * as outer angle.
  52455. */
  52456. set innerAngle(value: number);
  52457. private _shadowAngleScale;
  52458. /**
  52459. * Allows scaling the angle of the light for shadow generation only.
  52460. */
  52461. get shadowAngleScale(): number;
  52462. /**
  52463. * Allows scaling the angle of the light for shadow generation only.
  52464. */
  52465. set shadowAngleScale(value: number);
  52466. /**
  52467. * The light decay speed with the distance from the emission spot.
  52468. */
  52469. exponent: number;
  52470. private _projectionTextureMatrix;
  52471. /**
  52472. * Allows reading the projecton texture
  52473. */
  52474. get projectionTextureMatrix(): Matrix;
  52475. protected _projectionTextureLightNear: number;
  52476. /**
  52477. * Gets the near clip of the Spotlight for texture projection.
  52478. */
  52479. get projectionTextureLightNear(): number;
  52480. /**
  52481. * Sets the near clip of the Spotlight for texture projection.
  52482. */
  52483. set projectionTextureLightNear(value: number);
  52484. protected _projectionTextureLightFar: number;
  52485. /**
  52486. * Gets the far clip of the Spotlight for texture projection.
  52487. */
  52488. get projectionTextureLightFar(): number;
  52489. /**
  52490. * Sets the far clip of the Spotlight for texture projection.
  52491. */
  52492. set projectionTextureLightFar(value: number);
  52493. protected _projectionTextureUpDirection: Vector3;
  52494. /**
  52495. * Gets the Up vector of the Spotlight for texture projection.
  52496. */
  52497. get projectionTextureUpDirection(): Vector3;
  52498. /**
  52499. * Sets the Up vector of the Spotlight for texture projection.
  52500. */
  52501. set projectionTextureUpDirection(value: Vector3);
  52502. private _projectionTexture;
  52503. /**
  52504. * Gets the projection texture of the light.
  52505. */
  52506. get projectionTexture(): Nullable<BaseTexture>;
  52507. /**
  52508. * Sets the projection texture of the light.
  52509. */
  52510. set projectionTexture(value: Nullable<BaseTexture>);
  52511. private _projectionTextureViewLightDirty;
  52512. private _projectionTextureProjectionLightDirty;
  52513. private _projectionTextureDirty;
  52514. private _projectionTextureViewTargetVector;
  52515. private _projectionTextureViewLightMatrix;
  52516. private _projectionTextureProjectionLightMatrix;
  52517. private _projectionTextureScalingMatrix;
  52518. /**
  52519. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52520. * It can cast shadows.
  52521. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52522. * @param name The light friendly name
  52523. * @param position The position of the spot light in the scene
  52524. * @param direction The direction of the light in the scene
  52525. * @param angle The cone angle of the light in Radians
  52526. * @param exponent The light decay speed with the distance from the emission spot
  52527. * @param scene The scene the lights belongs to
  52528. */
  52529. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52530. /**
  52531. * Returns the string "SpotLight".
  52532. * @returns the class name
  52533. */
  52534. getClassName(): string;
  52535. /**
  52536. * Returns the integer 2.
  52537. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52538. */
  52539. getTypeID(): number;
  52540. /**
  52541. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52542. */
  52543. protected _setDirection(value: Vector3): void;
  52544. /**
  52545. * Overrides the position setter to recompute the projection texture view light Matrix.
  52546. */
  52547. protected _setPosition(value: Vector3): void;
  52548. /**
  52549. * 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.
  52550. * Returns the SpotLight.
  52551. */
  52552. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52553. protected _computeProjectionTextureViewLightMatrix(): void;
  52554. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52555. /**
  52556. * Main function for light texture projection matrix computing.
  52557. */
  52558. protected _computeProjectionTextureMatrix(): void;
  52559. protected _buildUniformLayout(): void;
  52560. private _computeAngleValues;
  52561. /**
  52562. * Sets the passed Effect "effect" with the Light textures.
  52563. * @param effect The effect to update
  52564. * @param lightIndex The index of the light in the effect to update
  52565. * @returns The light
  52566. */
  52567. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52568. /**
  52569. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52570. * @param effect The effect to update
  52571. * @param lightIndex The index of the light in the effect to update
  52572. * @returns The spot light
  52573. */
  52574. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52575. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52576. /**
  52577. * Disposes the light and the associated resources.
  52578. */
  52579. dispose(): void;
  52580. /**
  52581. * Prepares the list of defines specific to the light type.
  52582. * @param defines the list of defines
  52583. * @param lightIndex defines the index of the light for the effect
  52584. */
  52585. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52586. }
  52587. }
  52588. declare module BABYLON {
  52589. /**
  52590. * Gizmo that enables viewing a light
  52591. */
  52592. export class LightGizmo extends Gizmo {
  52593. private _lightMesh;
  52594. private _material;
  52595. private _cachedPosition;
  52596. private _cachedForward;
  52597. private _attachedMeshParent;
  52598. /**
  52599. * Creates a LightGizmo
  52600. * @param gizmoLayer The utility layer the gizmo will be added to
  52601. */
  52602. constructor(gizmoLayer?: UtilityLayerRenderer);
  52603. private _light;
  52604. /**
  52605. * The light that the gizmo is attached to
  52606. */
  52607. set light(light: Nullable<Light>);
  52608. get light(): Nullable<Light>;
  52609. /**
  52610. * Gets the material used to render the light gizmo
  52611. */
  52612. get material(): StandardMaterial;
  52613. /**
  52614. * @hidden
  52615. * Updates the gizmo to match the attached mesh's position/rotation
  52616. */
  52617. protected _update(): void;
  52618. private static _Scale;
  52619. /**
  52620. * Creates the lines for a light mesh
  52621. */
  52622. private static _CreateLightLines;
  52623. /**
  52624. * Disposes of the light gizmo
  52625. */
  52626. dispose(): void;
  52627. private static _CreateHemisphericLightMesh;
  52628. private static _CreatePointLightMesh;
  52629. private static _CreateSpotLightMesh;
  52630. private static _CreateDirectionalLightMesh;
  52631. }
  52632. }
  52633. declare module BABYLON {
  52634. /** @hidden */
  52635. export var backgroundFragmentDeclaration: {
  52636. name: string;
  52637. shader: string;
  52638. };
  52639. }
  52640. declare module BABYLON {
  52641. /** @hidden */
  52642. export var backgroundUboDeclaration: {
  52643. name: string;
  52644. shader: string;
  52645. };
  52646. }
  52647. declare module BABYLON {
  52648. /** @hidden */
  52649. export var backgroundPixelShader: {
  52650. name: string;
  52651. shader: string;
  52652. };
  52653. }
  52654. declare module BABYLON {
  52655. /** @hidden */
  52656. export var backgroundVertexDeclaration: {
  52657. name: string;
  52658. shader: string;
  52659. };
  52660. }
  52661. declare module BABYLON {
  52662. /** @hidden */
  52663. export var backgroundVertexShader: {
  52664. name: string;
  52665. shader: string;
  52666. };
  52667. }
  52668. declare module BABYLON {
  52669. /**
  52670. * Background material used to create an efficient environement around your scene.
  52671. */
  52672. export class BackgroundMaterial extends PushMaterial {
  52673. /**
  52674. * Standard reflectance value at parallel view angle.
  52675. */
  52676. static StandardReflectance0: number;
  52677. /**
  52678. * Standard reflectance value at grazing angle.
  52679. */
  52680. static StandardReflectance90: number;
  52681. protected _primaryColor: Color3;
  52682. /**
  52683. * Key light Color (multiply against the environement texture)
  52684. */
  52685. primaryColor: Color3;
  52686. protected __perceptualColor: Nullable<Color3>;
  52687. /**
  52688. * Experimental Internal Use Only.
  52689. *
  52690. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  52691. * This acts as a helper to set the primary color to a more "human friendly" value.
  52692. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  52693. * output color as close as possible from the chosen value.
  52694. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  52695. * part of lighting setup.)
  52696. */
  52697. get _perceptualColor(): Nullable<Color3>;
  52698. set _perceptualColor(value: Nullable<Color3>);
  52699. protected _primaryColorShadowLevel: float;
  52700. /**
  52701. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  52702. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  52703. */
  52704. get primaryColorShadowLevel(): float;
  52705. set primaryColorShadowLevel(value: float);
  52706. protected _primaryColorHighlightLevel: float;
  52707. /**
  52708. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  52709. * The primary color is used at the level chosen to define what the white area would look.
  52710. */
  52711. get primaryColorHighlightLevel(): float;
  52712. set primaryColorHighlightLevel(value: float);
  52713. protected _reflectionTexture: Nullable<BaseTexture>;
  52714. /**
  52715. * Reflection Texture used in the material.
  52716. * Should be author in a specific way for the best result (refer to the documentation).
  52717. */
  52718. reflectionTexture: Nullable<BaseTexture>;
  52719. protected _reflectionBlur: float;
  52720. /**
  52721. * Reflection Texture level of blur.
  52722. *
  52723. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  52724. * texture twice.
  52725. */
  52726. reflectionBlur: float;
  52727. protected _diffuseTexture: Nullable<BaseTexture>;
  52728. /**
  52729. * Diffuse Texture used in the material.
  52730. * Should be author in a specific way for the best result (refer to the documentation).
  52731. */
  52732. diffuseTexture: Nullable<BaseTexture>;
  52733. protected _shadowLights: Nullable<IShadowLight[]>;
  52734. /**
  52735. * Specify the list of lights casting shadow on the material.
  52736. * All scene shadow lights will be included if null.
  52737. */
  52738. shadowLights: Nullable<IShadowLight[]>;
  52739. protected _shadowLevel: float;
  52740. /**
  52741. * Helps adjusting the shadow to a softer level if required.
  52742. * 0 means black shadows and 1 means no shadows.
  52743. */
  52744. shadowLevel: float;
  52745. protected _sceneCenter: Vector3;
  52746. /**
  52747. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  52748. * It is usually zero but might be interesting to modify according to your setup.
  52749. */
  52750. sceneCenter: Vector3;
  52751. protected _opacityFresnel: boolean;
  52752. /**
  52753. * This helps specifying that the material is falling off to the sky box at grazing angle.
  52754. * This helps ensuring a nice transition when the camera goes under the ground.
  52755. */
  52756. opacityFresnel: boolean;
  52757. protected _reflectionFresnel: boolean;
  52758. /**
  52759. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  52760. * This helps adding a mirror texture on the ground.
  52761. */
  52762. reflectionFresnel: boolean;
  52763. protected _reflectionFalloffDistance: number;
  52764. /**
  52765. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  52766. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  52767. */
  52768. reflectionFalloffDistance: number;
  52769. protected _reflectionAmount: number;
  52770. /**
  52771. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  52772. */
  52773. reflectionAmount: number;
  52774. protected _reflectionReflectance0: number;
  52775. /**
  52776. * This specifies the weight of the reflection at grazing angle.
  52777. */
  52778. reflectionReflectance0: number;
  52779. protected _reflectionReflectance90: number;
  52780. /**
  52781. * This specifies the weight of the reflection at a perpendicular point of view.
  52782. */
  52783. reflectionReflectance90: number;
  52784. /**
  52785. * Sets the reflection reflectance fresnel values according to the default standard
  52786. * empirically know to work well :-)
  52787. */
  52788. set reflectionStandardFresnelWeight(value: number);
  52789. protected _useRGBColor: boolean;
  52790. /**
  52791. * Helps to directly use the maps channels instead of their level.
  52792. */
  52793. useRGBColor: boolean;
  52794. protected _enableNoise: boolean;
  52795. /**
  52796. * This helps reducing the banding effect that could occur on the background.
  52797. */
  52798. enableNoise: boolean;
  52799. /**
  52800. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52801. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  52802. * Recommended to be keep at 1.0 except for special cases.
  52803. */
  52804. get fovMultiplier(): number;
  52805. set fovMultiplier(value: number);
  52806. private _fovMultiplier;
  52807. /**
  52808. * Enable the FOV adjustment feature controlled by fovMultiplier.
  52809. */
  52810. useEquirectangularFOV: boolean;
  52811. private _maxSimultaneousLights;
  52812. /**
  52813. * Number of Simultaneous lights allowed on the material.
  52814. */
  52815. maxSimultaneousLights: int;
  52816. /**
  52817. * Default configuration related to image processing available in the Background Material.
  52818. */
  52819. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52820. /**
  52821. * Keep track of the image processing observer to allow dispose and replace.
  52822. */
  52823. private _imageProcessingObserver;
  52824. /**
  52825. * Attaches a new image processing configuration to the PBR Material.
  52826. * @param configuration (if null the scene configuration will be use)
  52827. */
  52828. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52829. /**
  52830. * Gets the image processing configuration used either in this material.
  52831. */
  52832. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  52833. /**
  52834. * Sets the Default image processing configuration used either in the this material.
  52835. *
  52836. * If sets to null, the scene one is in use.
  52837. */
  52838. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  52839. /**
  52840. * Gets wether the color curves effect is enabled.
  52841. */
  52842. get cameraColorCurvesEnabled(): boolean;
  52843. /**
  52844. * Sets wether the color curves effect is enabled.
  52845. */
  52846. set cameraColorCurvesEnabled(value: boolean);
  52847. /**
  52848. * Gets wether the color grading effect is enabled.
  52849. */
  52850. get cameraColorGradingEnabled(): boolean;
  52851. /**
  52852. * Gets wether the color grading effect is enabled.
  52853. */
  52854. set cameraColorGradingEnabled(value: boolean);
  52855. /**
  52856. * Gets wether tonemapping is enabled or not.
  52857. */
  52858. get cameraToneMappingEnabled(): boolean;
  52859. /**
  52860. * Sets wether tonemapping is enabled or not
  52861. */
  52862. set cameraToneMappingEnabled(value: boolean);
  52863. /**
  52864. * The camera exposure used on this material.
  52865. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52866. * This corresponds to a photographic exposure.
  52867. */
  52868. get cameraExposure(): float;
  52869. /**
  52870. * The camera exposure used on this material.
  52871. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52872. * This corresponds to a photographic exposure.
  52873. */
  52874. set cameraExposure(value: float);
  52875. /**
  52876. * Gets The camera contrast used on this material.
  52877. */
  52878. get cameraContrast(): float;
  52879. /**
  52880. * Sets The camera contrast used on this material.
  52881. */
  52882. set cameraContrast(value: float);
  52883. /**
  52884. * Gets the Color Grading 2D Lookup Texture.
  52885. */
  52886. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52887. /**
  52888. * Sets the Color Grading 2D Lookup Texture.
  52889. */
  52890. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52891. /**
  52892. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52893. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52894. * 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;
  52895. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52896. */
  52897. get cameraColorCurves(): Nullable<ColorCurves>;
  52898. /**
  52899. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52900. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52901. * 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;
  52902. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52903. */
  52904. set cameraColorCurves(value: Nullable<ColorCurves>);
  52905. /**
  52906. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  52907. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  52908. */
  52909. switchToBGR: boolean;
  52910. private _renderTargets;
  52911. private _reflectionControls;
  52912. private _white;
  52913. private _primaryShadowColor;
  52914. private _primaryHighlightColor;
  52915. /**
  52916. * Instantiates a Background Material in the given scene
  52917. * @param name The friendly name of the material
  52918. * @param scene The scene to add the material to
  52919. */
  52920. constructor(name: string, scene: Scene);
  52921. /**
  52922. * Gets a boolean indicating that current material needs to register RTT
  52923. */
  52924. get hasRenderTargetTextures(): boolean;
  52925. /**
  52926. * The entire material has been created in order to prevent overdraw.
  52927. * @returns false
  52928. */
  52929. needAlphaTesting(): boolean;
  52930. /**
  52931. * The entire material has been created in order to prevent overdraw.
  52932. * @returns true if blending is enable
  52933. */
  52934. needAlphaBlending(): boolean;
  52935. /**
  52936. * Checks wether the material is ready to be rendered for a given mesh.
  52937. * @param mesh The mesh to render
  52938. * @param subMesh The submesh to check against
  52939. * @param useInstances Specify wether or not the material is used with instances
  52940. * @returns true if all the dependencies are ready (Textures, Effects...)
  52941. */
  52942. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52943. /**
  52944. * Compute the primary color according to the chosen perceptual color.
  52945. */
  52946. private _computePrimaryColorFromPerceptualColor;
  52947. /**
  52948. * Compute the highlights and shadow colors according to their chosen levels.
  52949. */
  52950. private _computePrimaryColors;
  52951. /**
  52952. * Build the uniform buffer used in the material.
  52953. */
  52954. buildUniformLayout(): void;
  52955. /**
  52956. * Unbind the material.
  52957. */
  52958. unbind(): void;
  52959. /**
  52960. * Bind only the world matrix to the material.
  52961. * @param world The world matrix to bind.
  52962. */
  52963. bindOnlyWorldMatrix(world: Matrix): void;
  52964. /**
  52965. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  52966. * @param world The world matrix to bind.
  52967. * @param subMesh The submesh to bind for.
  52968. */
  52969. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52970. /**
  52971. * Checks to see if a texture is used in the material.
  52972. * @param texture - Base texture to use.
  52973. * @returns - Boolean specifying if a texture is used in the material.
  52974. */
  52975. hasTexture(texture: BaseTexture): boolean;
  52976. /**
  52977. * Dispose the material.
  52978. * @param forceDisposeEffect Force disposal of the associated effect.
  52979. * @param forceDisposeTextures Force disposal of the associated textures.
  52980. */
  52981. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52982. /**
  52983. * Clones the material.
  52984. * @param name The cloned name.
  52985. * @returns The cloned material.
  52986. */
  52987. clone(name: string): BackgroundMaterial;
  52988. /**
  52989. * Serializes the current material to its JSON representation.
  52990. * @returns The JSON representation.
  52991. */
  52992. serialize(): any;
  52993. /**
  52994. * Gets the class name of the material
  52995. * @returns "BackgroundMaterial"
  52996. */
  52997. getClassName(): string;
  52998. /**
  52999. * Parse a JSON input to create back a background material.
  53000. * @param source The JSON data to parse
  53001. * @param scene The scene to create the parsed material in
  53002. * @param rootUrl The root url of the assets the material depends upon
  53003. * @returns the instantiated BackgroundMaterial.
  53004. */
  53005. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53006. }
  53007. }
  53008. declare module BABYLON {
  53009. /**
  53010. * Represents the different options available during the creation of
  53011. * a Environment helper.
  53012. *
  53013. * This can control the default ground, skybox and image processing setup of your scene.
  53014. */
  53015. export interface IEnvironmentHelperOptions {
  53016. /**
  53017. * Specifies whether or not to create a ground.
  53018. * True by default.
  53019. */
  53020. createGround: boolean;
  53021. /**
  53022. * Specifies the ground size.
  53023. * 15 by default.
  53024. */
  53025. groundSize: number;
  53026. /**
  53027. * The texture used on the ground for the main color.
  53028. * Comes from the BabylonJS CDN by default.
  53029. *
  53030. * Remarks: Can be either a texture or a url.
  53031. */
  53032. groundTexture: string | BaseTexture;
  53033. /**
  53034. * The color mixed in the ground texture by default.
  53035. * BabylonJS clearColor by default.
  53036. */
  53037. groundColor: Color3;
  53038. /**
  53039. * Specifies the ground opacity.
  53040. * 1 by default.
  53041. */
  53042. groundOpacity: number;
  53043. /**
  53044. * Enables the ground to receive shadows.
  53045. * True by default.
  53046. */
  53047. enableGroundShadow: boolean;
  53048. /**
  53049. * Helps preventing the shadow to be fully black on the ground.
  53050. * 0.5 by default.
  53051. */
  53052. groundShadowLevel: number;
  53053. /**
  53054. * Creates a mirror texture attach to the ground.
  53055. * false by default.
  53056. */
  53057. enableGroundMirror: boolean;
  53058. /**
  53059. * Specifies the ground mirror size ratio.
  53060. * 0.3 by default as the default kernel is 64.
  53061. */
  53062. groundMirrorSizeRatio: number;
  53063. /**
  53064. * Specifies the ground mirror blur kernel size.
  53065. * 64 by default.
  53066. */
  53067. groundMirrorBlurKernel: number;
  53068. /**
  53069. * Specifies the ground mirror visibility amount.
  53070. * 1 by default
  53071. */
  53072. groundMirrorAmount: number;
  53073. /**
  53074. * Specifies the ground mirror reflectance weight.
  53075. * This uses the standard weight of the background material to setup the fresnel effect
  53076. * of the mirror.
  53077. * 1 by default.
  53078. */
  53079. groundMirrorFresnelWeight: number;
  53080. /**
  53081. * Specifies the ground mirror Falloff distance.
  53082. * This can helps reducing the size of the reflection.
  53083. * 0 by Default.
  53084. */
  53085. groundMirrorFallOffDistance: number;
  53086. /**
  53087. * Specifies the ground mirror texture type.
  53088. * Unsigned Int by Default.
  53089. */
  53090. groundMirrorTextureType: number;
  53091. /**
  53092. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53093. * the shown objects.
  53094. */
  53095. groundYBias: number;
  53096. /**
  53097. * Specifies whether or not to create a skybox.
  53098. * True by default.
  53099. */
  53100. createSkybox: boolean;
  53101. /**
  53102. * Specifies the skybox size.
  53103. * 20 by default.
  53104. */
  53105. skyboxSize: number;
  53106. /**
  53107. * The texture used on the skybox for the main color.
  53108. * Comes from the BabylonJS CDN by default.
  53109. *
  53110. * Remarks: Can be either a texture or a url.
  53111. */
  53112. skyboxTexture: string | BaseTexture;
  53113. /**
  53114. * The color mixed in the skybox texture by default.
  53115. * BabylonJS clearColor by default.
  53116. */
  53117. skyboxColor: Color3;
  53118. /**
  53119. * The background rotation around the Y axis of the scene.
  53120. * This helps aligning the key lights of your scene with the background.
  53121. * 0 by default.
  53122. */
  53123. backgroundYRotation: number;
  53124. /**
  53125. * Compute automatically the size of the elements to best fit with the scene.
  53126. */
  53127. sizeAuto: boolean;
  53128. /**
  53129. * Default position of the rootMesh if autoSize is not true.
  53130. */
  53131. rootPosition: Vector3;
  53132. /**
  53133. * Sets up the image processing in the scene.
  53134. * true by default.
  53135. */
  53136. setupImageProcessing: boolean;
  53137. /**
  53138. * The texture used as your environment texture in the scene.
  53139. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53140. *
  53141. * Remarks: Can be either a texture or a url.
  53142. */
  53143. environmentTexture: string | BaseTexture;
  53144. /**
  53145. * The value of the exposure to apply to the scene.
  53146. * 0.6 by default if setupImageProcessing is true.
  53147. */
  53148. cameraExposure: number;
  53149. /**
  53150. * The value of the contrast to apply to the scene.
  53151. * 1.6 by default if setupImageProcessing is true.
  53152. */
  53153. cameraContrast: number;
  53154. /**
  53155. * Specifies whether or not tonemapping should be enabled in the scene.
  53156. * true by default if setupImageProcessing is true.
  53157. */
  53158. toneMappingEnabled: boolean;
  53159. }
  53160. /**
  53161. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53162. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53163. * It also helps with the default setup of your imageProcessing configuration.
  53164. */
  53165. export class EnvironmentHelper {
  53166. /**
  53167. * Default ground texture URL.
  53168. */
  53169. private static _groundTextureCDNUrl;
  53170. /**
  53171. * Default skybox texture URL.
  53172. */
  53173. private static _skyboxTextureCDNUrl;
  53174. /**
  53175. * Default environment texture URL.
  53176. */
  53177. private static _environmentTextureCDNUrl;
  53178. /**
  53179. * Creates the default options for the helper.
  53180. */
  53181. private static _getDefaultOptions;
  53182. private _rootMesh;
  53183. /**
  53184. * Gets the root mesh created by the helper.
  53185. */
  53186. get rootMesh(): Mesh;
  53187. private _skybox;
  53188. /**
  53189. * Gets the skybox created by the helper.
  53190. */
  53191. get skybox(): Nullable<Mesh>;
  53192. private _skyboxTexture;
  53193. /**
  53194. * Gets the skybox texture created by the helper.
  53195. */
  53196. get skyboxTexture(): Nullable<BaseTexture>;
  53197. private _skyboxMaterial;
  53198. /**
  53199. * Gets the skybox material created by the helper.
  53200. */
  53201. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53202. private _ground;
  53203. /**
  53204. * Gets the ground mesh created by the helper.
  53205. */
  53206. get ground(): Nullable<Mesh>;
  53207. private _groundTexture;
  53208. /**
  53209. * Gets the ground texture created by the helper.
  53210. */
  53211. get groundTexture(): Nullable<BaseTexture>;
  53212. private _groundMirror;
  53213. /**
  53214. * Gets the ground mirror created by the helper.
  53215. */
  53216. get groundMirror(): Nullable<MirrorTexture>;
  53217. /**
  53218. * Gets the ground mirror render list to helps pushing the meshes
  53219. * you wish in the ground reflection.
  53220. */
  53221. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53222. private _groundMaterial;
  53223. /**
  53224. * Gets the ground material created by the helper.
  53225. */
  53226. get groundMaterial(): Nullable<BackgroundMaterial>;
  53227. /**
  53228. * Stores the creation options.
  53229. */
  53230. private readonly _scene;
  53231. private _options;
  53232. /**
  53233. * This observable will be notified with any error during the creation of the environment,
  53234. * mainly texture creation errors.
  53235. */
  53236. onErrorObservable: Observable<{
  53237. message?: string;
  53238. exception?: any;
  53239. }>;
  53240. /**
  53241. * constructor
  53242. * @param options Defines the options we want to customize the helper
  53243. * @param scene The scene to add the material to
  53244. */
  53245. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53246. /**
  53247. * Updates the background according to the new options
  53248. * @param options
  53249. */
  53250. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53251. /**
  53252. * Sets the primary color of all the available elements.
  53253. * @param color the main color to affect to the ground and the background
  53254. */
  53255. setMainColor(color: Color3): void;
  53256. /**
  53257. * Setup the image processing according to the specified options.
  53258. */
  53259. private _setupImageProcessing;
  53260. /**
  53261. * Setup the environment texture according to the specified options.
  53262. */
  53263. private _setupEnvironmentTexture;
  53264. /**
  53265. * Setup the background according to the specified options.
  53266. */
  53267. private _setupBackground;
  53268. /**
  53269. * Get the scene sizes according to the setup.
  53270. */
  53271. private _getSceneSize;
  53272. /**
  53273. * Setup the ground according to the specified options.
  53274. */
  53275. private _setupGround;
  53276. /**
  53277. * Setup the ground material according to the specified options.
  53278. */
  53279. private _setupGroundMaterial;
  53280. /**
  53281. * Setup the ground diffuse texture according to the specified options.
  53282. */
  53283. private _setupGroundDiffuseTexture;
  53284. /**
  53285. * Setup the ground mirror texture according to the specified options.
  53286. */
  53287. private _setupGroundMirrorTexture;
  53288. /**
  53289. * Setup the ground to receive the mirror texture.
  53290. */
  53291. private _setupMirrorInGroundMaterial;
  53292. /**
  53293. * Setup the skybox according to the specified options.
  53294. */
  53295. private _setupSkybox;
  53296. /**
  53297. * Setup the skybox material according to the specified options.
  53298. */
  53299. private _setupSkyboxMaterial;
  53300. /**
  53301. * Setup the skybox reflection texture according to the specified options.
  53302. */
  53303. private _setupSkyboxReflectionTexture;
  53304. private _errorHandler;
  53305. /**
  53306. * Dispose all the elements created by the Helper.
  53307. */
  53308. dispose(): void;
  53309. }
  53310. }
  53311. declare module BABYLON {
  53312. /**
  53313. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53314. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53315. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53316. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53317. */
  53318. export class PhotoDome extends TransformNode {
  53319. /**
  53320. * Define the image as a Monoscopic panoramic 360 image.
  53321. */
  53322. static readonly MODE_MONOSCOPIC: number;
  53323. /**
  53324. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53325. */
  53326. static readonly MODE_TOPBOTTOM: number;
  53327. /**
  53328. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53329. */
  53330. static readonly MODE_SIDEBYSIDE: number;
  53331. private _useDirectMapping;
  53332. /**
  53333. * The texture being displayed on the sphere
  53334. */
  53335. protected _photoTexture: Texture;
  53336. /**
  53337. * Gets or sets the texture being displayed on the sphere
  53338. */
  53339. get photoTexture(): Texture;
  53340. set photoTexture(value: Texture);
  53341. /**
  53342. * Observable raised when an error occured while loading the 360 image
  53343. */
  53344. onLoadErrorObservable: Observable<string>;
  53345. /**
  53346. * The skybox material
  53347. */
  53348. protected _material: BackgroundMaterial;
  53349. /**
  53350. * The surface used for the skybox
  53351. */
  53352. protected _mesh: Mesh;
  53353. /**
  53354. * Gets the mesh used for the skybox.
  53355. */
  53356. get mesh(): Mesh;
  53357. /**
  53358. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53359. * Also see the options.resolution property.
  53360. */
  53361. get fovMultiplier(): number;
  53362. set fovMultiplier(value: number);
  53363. private _imageMode;
  53364. /**
  53365. * Gets or set the current video mode for the video. It can be:
  53366. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53367. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53368. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53369. */
  53370. get imageMode(): number;
  53371. set imageMode(value: number);
  53372. /**
  53373. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53374. * @param name Element's name, child elements will append suffixes for their own names.
  53375. * @param urlsOfPhoto defines the url of the photo to display
  53376. * @param options defines an object containing optional or exposed sub element properties
  53377. * @param onError defines a callback called when an error occured while loading the texture
  53378. */
  53379. constructor(name: string, urlOfPhoto: string, options: {
  53380. resolution?: number;
  53381. size?: number;
  53382. useDirectMapping?: boolean;
  53383. faceForward?: boolean;
  53384. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53385. private _onBeforeCameraRenderObserver;
  53386. private _changeImageMode;
  53387. /**
  53388. * Releases resources associated with this node.
  53389. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53390. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53391. */
  53392. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53393. }
  53394. }
  53395. declare module BABYLON {
  53396. /**
  53397. * Class used to host RGBD texture specific utilities
  53398. */
  53399. export class RGBDTextureTools {
  53400. /**
  53401. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53402. * @param texture the texture to expand.
  53403. */
  53404. static ExpandRGBDTexture(texture: Texture): void;
  53405. }
  53406. }
  53407. declare module BABYLON {
  53408. /**
  53409. * Class used to host texture specific utilities
  53410. */
  53411. export class BRDFTextureTools {
  53412. /**
  53413. * Prevents texture cache collision
  53414. */
  53415. private static _instanceNumber;
  53416. /**
  53417. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53418. * @param scene defines the hosting scene
  53419. * @returns the environment BRDF texture
  53420. */
  53421. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53422. private static _environmentBRDFBase64Texture;
  53423. }
  53424. }
  53425. declare module BABYLON {
  53426. /**
  53427. * @hidden
  53428. */
  53429. export interface IMaterialClearCoatDefines {
  53430. CLEARCOAT: boolean;
  53431. CLEARCOAT_DEFAULTIOR: boolean;
  53432. CLEARCOAT_TEXTURE: boolean;
  53433. CLEARCOAT_TEXTUREDIRECTUV: number;
  53434. CLEARCOAT_BUMP: boolean;
  53435. CLEARCOAT_BUMPDIRECTUV: number;
  53436. CLEARCOAT_TINT: boolean;
  53437. CLEARCOAT_TINT_TEXTURE: boolean;
  53438. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53439. /** @hidden */
  53440. _areTexturesDirty: boolean;
  53441. }
  53442. /**
  53443. * Define the code related to the clear coat parameters of the pbr material.
  53444. */
  53445. export class PBRClearCoatConfiguration {
  53446. /**
  53447. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53448. * The default fits with a polyurethane material.
  53449. */
  53450. private static readonly _DefaultIndexOfRefraction;
  53451. private _isEnabled;
  53452. /**
  53453. * Defines if the clear coat is enabled in the material.
  53454. */
  53455. isEnabled: boolean;
  53456. /**
  53457. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53458. */
  53459. intensity: number;
  53460. /**
  53461. * Defines the clear coat layer roughness.
  53462. */
  53463. roughness: number;
  53464. private _indexOfRefraction;
  53465. /**
  53466. * Defines the index of refraction of the clear coat.
  53467. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53468. * The default fits with a polyurethane material.
  53469. * Changing the default value is more performance intensive.
  53470. */
  53471. indexOfRefraction: number;
  53472. private _texture;
  53473. /**
  53474. * Stores the clear coat values in a texture.
  53475. */
  53476. texture: Nullable<BaseTexture>;
  53477. private _bumpTexture;
  53478. /**
  53479. * Define the clear coat specific bump texture.
  53480. */
  53481. bumpTexture: Nullable<BaseTexture>;
  53482. private _isTintEnabled;
  53483. /**
  53484. * Defines if the clear coat tint is enabled in the material.
  53485. */
  53486. isTintEnabled: boolean;
  53487. /**
  53488. * Defines the clear coat tint of the material.
  53489. * This is only use if tint is enabled
  53490. */
  53491. tintColor: Color3;
  53492. /**
  53493. * Defines the distance at which the tint color should be found in the
  53494. * clear coat media.
  53495. * This is only use if tint is enabled
  53496. */
  53497. tintColorAtDistance: number;
  53498. /**
  53499. * Defines the clear coat layer thickness.
  53500. * This is only use if tint is enabled
  53501. */
  53502. tintThickness: number;
  53503. private _tintTexture;
  53504. /**
  53505. * Stores the clear tint values in a texture.
  53506. * rgb is tint
  53507. * a is a thickness factor
  53508. */
  53509. tintTexture: Nullable<BaseTexture>;
  53510. /** @hidden */
  53511. private _internalMarkAllSubMeshesAsTexturesDirty;
  53512. /** @hidden */
  53513. _markAllSubMeshesAsTexturesDirty(): void;
  53514. /**
  53515. * Instantiate a new istance of clear coat configuration.
  53516. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53517. */
  53518. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53519. /**
  53520. * Gets wehter the submesh is ready to be used or not.
  53521. * @param defines the list of "defines" to update.
  53522. * @param scene defines the scene the material belongs to.
  53523. * @param engine defines the engine the material belongs to.
  53524. * @param disableBumpMap defines wether the material disables bump or not.
  53525. * @returns - boolean indicating that the submesh is ready or not.
  53526. */
  53527. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53528. /**
  53529. * Checks to see if a texture is used in the material.
  53530. * @param defines the list of "defines" to update.
  53531. * @param scene defines the scene to the material belongs to.
  53532. */
  53533. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53534. /**
  53535. * Binds the material data.
  53536. * @param uniformBuffer defines the Uniform buffer to fill in.
  53537. * @param scene defines the scene the material belongs to.
  53538. * @param engine defines the engine the material belongs to.
  53539. * @param disableBumpMap defines wether the material disables bump or not.
  53540. * @param isFrozen defines wether the material is frozen or not.
  53541. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53542. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53543. */
  53544. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53545. /**
  53546. * Checks to see if a texture is used in the material.
  53547. * @param texture - Base texture to use.
  53548. * @returns - Boolean specifying if a texture is used in the material.
  53549. */
  53550. hasTexture(texture: BaseTexture): boolean;
  53551. /**
  53552. * Returns an array of the actively used textures.
  53553. * @param activeTextures Array of BaseTextures
  53554. */
  53555. getActiveTextures(activeTextures: BaseTexture[]): void;
  53556. /**
  53557. * Returns the animatable textures.
  53558. * @param animatables Array of animatable textures.
  53559. */
  53560. getAnimatables(animatables: IAnimatable[]): void;
  53561. /**
  53562. * Disposes the resources of the material.
  53563. * @param forceDisposeTextures - Forces the disposal of all textures.
  53564. */
  53565. dispose(forceDisposeTextures?: boolean): void;
  53566. /**
  53567. * Get the current class name of the texture useful for serialization or dynamic coding.
  53568. * @returns "PBRClearCoatConfiguration"
  53569. */
  53570. getClassName(): string;
  53571. /**
  53572. * Add fallbacks to the effect fallbacks list.
  53573. * @param defines defines the Base texture to use.
  53574. * @param fallbacks defines the current fallback list.
  53575. * @param currentRank defines the current fallback rank.
  53576. * @returns the new fallback rank.
  53577. */
  53578. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53579. /**
  53580. * Add the required uniforms to the current list.
  53581. * @param uniforms defines the current uniform list.
  53582. */
  53583. static AddUniforms(uniforms: string[]): void;
  53584. /**
  53585. * Add the required samplers to the current list.
  53586. * @param samplers defines the current sampler list.
  53587. */
  53588. static AddSamplers(samplers: string[]): void;
  53589. /**
  53590. * Add the required uniforms to the current buffer.
  53591. * @param uniformBuffer defines the current uniform buffer.
  53592. */
  53593. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53594. /**
  53595. * Makes a duplicate of the current configuration into another one.
  53596. * @param clearCoatConfiguration define the config where to copy the info
  53597. */
  53598. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  53599. /**
  53600. * Serializes this clear coat configuration.
  53601. * @returns - An object with the serialized config.
  53602. */
  53603. serialize(): any;
  53604. /**
  53605. * Parses a anisotropy Configuration from a serialized object.
  53606. * @param source - Serialized object.
  53607. * @param scene Defines the scene we are parsing for
  53608. * @param rootUrl Defines the rootUrl to load from
  53609. */
  53610. parse(source: any, scene: Scene, rootUrl: string): void;
  53611. }
  53612. }
  53613. declare module BABYLON {
  53614. /**
  53615. * @hidden
  53616. */
  53617. export interface IMaterialAnisotropicDefines {
  53618. ANISOTROPIC: boolean;
  53619. ANISOTROPIC_TEXTURE: boolean;
  53620. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53621. MAINUV1: boolean;
  53622. _areTexturesDirty: boolean;
  53623. _needUVs: boolean;
  53624. }
  53625. /**
  53626. * Define the code related to the anisotropic parameters of the pbr material.
  53627. */
  53628. export class PBRAnisotropicConfiguration {
  53629. private _isEnabled;
  53630. /**
  53631. * Defines if the anisotropy is enabled in the material.
  53632. */
  53633. isEnabled: boolean;
  53634. /**
  53635. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  53636. */
  53637. intensity: number;
  53638. /**
  53639. * Defines if the effect is along the tangents, bitangents or in between.
  53640. * By default, the effect is "strectching" the highlights along the tangents.
  53641. */
  53642. direction: Vector2;
  53643. private _texture;
  53644. /**
  53645. * Stores the anisotropy values in a texture.
  53646. * rg is direction (like normal from -1 to 1)
  53647. * b is a intensity
  53648. */
  53649. texture: Nullable<BaseTexture>;
  53650. /** @hidden */
  53651. private _internalMarkAllSubMeshesAsTexturesDirty;
  53652. /** @hidden */
  53653. _markAllSubMeshesAsTexturesDirty(): void;
  53654. /**
  53655. * Instantiate a new istance of anisotropy configuration.
  53656. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53657. */
  53658. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53659. /**
  53660. * Specifies that the submesh is ready to be used.
  53661. * @param defines the list of "defines" to update.
  53662. * @param scene defines the scene the material belongs to.
  53663. * @returns - boolean indicating that the submesh is ready or not.
  53664. */
  53665. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  53666. /**
  53667. * Checks to see if a texture is used in the material.
  53668. * @param defines the list of "defines" to update.
  53669. * @param mesh the mesh we are preparing the defines for.
  53670. * @param scene defines the scene the material belongs to.
  53671. */
  53672. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  53673. /**
  53674. * Binds the material data.
  53675. * @param uniformBuffer defines the Uniform buffer to fill in.
  53676. * @param scene defines the scene the material belongs to.
  53677. * @param isFrozen defines wether the material is frozen or not.
  53678. */
  53679. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53680. /**
  53681. * Checks to see if a texture is used in the material.
  53682. * @param texture - Base texture to use.
  53683. * @returns - Boolean specifying if a texture is used in the material.
  53684. */
  53685. hasTexture(texture: BaseTexture): boolean;
  53686. /**
  53687. * Returns an array of the actively used textures.
  53688. * @param activeTextures Array of BaseTextures
  53689. */
  53690. getActiveTextures(activeTextures: BaseTexture[]): void;
  53691. /**
  53692. * Returns the animatable textures.
  53693. * @param animatables Array of animatable textures.
  53694. */
  53695. getAnimatables(animatables: IAnimatable[]): void;
  53696. /**
  53697. * Disposes the resources of the material.
  53698. * @param forceDisposeTextures - Forces the disposal of all textures.
  53699. */
  53700. dispose(forceDisposeTextures?: boolean): void;
  53701. /**
  53702. * Get the current class name of the texture useful for serialization or dynamic coding.
  53703. * @returns "PBRAnisotropicConfiguration"
  53704. */
  53705. getClassName(): string;
  53706. /**
  53707. * Add fallbacks to the effect fallbacks list.
  53708. * @param defines defines the Base texture to use.
  53709. * @param fallbacks defines the current fallback list.
  53710. * @param currentRank defines the current fallback rank.
  53711. * @returns the new fallback rank.
  53712. */
  53713. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53714. /**
  53715. * Add the required uniforms to the current list.
  53716. * @param uniforms defines the current uniform list.
  53717. */
  53718. static AddUniforms(uniforms: string[]): void;
  53719. /**
  53720. * Add the required uniforms to the current buffer.
  53721. * @param uniformBuffer defines the current uniform buffer.
  53722. */
  53723. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53724. /**
  53725. * Add the required samplers to the current list.
  53726. * @param samplers defines the current sampler list.
  53727. */
  53728. static AddSamplers(samplers: string[]): void;
  53729. /**
  53730. * Makes a duplicate of the current configuration into another one.
  53731. * @param anisotropicConfiguration define the config where to copy the info
  53732. */
  53733. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  53734. /**
  53735. * Serializes this anisotropy configuration.
  53736. * @returns - An object with the serialized config.
  53737. */
  53738. serialize(): any;
  53739. /**
  53740. * Parses a anisotropy Configuration from a serialized object.
  53741. * @param source - Serialized object.
  53742. * @param scene Defines the scene we are parsing for
  53743. * @param rootUrl Defines the rootUrl to load from
  53744. */
  53745. parse(source: any, scene: Scene, rootUrl: string): void;
  53746. }
  53747. }
  53748. declare module BABYLON {
  53749. /**
  53750. * @hidden
  53751. */
  53752. export interface IMaterialBRDFDefines {
  53753. BRDF_V_HEIGHT_CORRELATED: boolean;
  53754. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53755. SPHERICAL_HARMONICS: boolean;
  53756. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53757. /** @hidden */
  53758. _areMiscDirty: boolean;
  53759. }
  53760. /**
  53761. * Define the code related to the BRDF parameters of the pbr material.
  53762. */
  53763. export class PBRBRDFConfiguration {
  53764. /**
  53765. * Default value used for the energy conservation.
  53766. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53767. */
  53768. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  53769. /**
  53770. * Default value used for the Smith Visibility Height Correlated mode.
  53771. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  53772. */
  53773. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  53774. /**
  53775. * Default value used for the IBL diffuse part.
  53776. * This can help switching back to the polynomials mode globally which is a tiny bit
  53777. * less GPU intensive at the drawback of a lower quality.
  53778. */
  53779. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  53780. /**
  53781. * Default value used for activating energy conservation for the specular workflow.
  53782. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53783. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53784. */
  53785. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  53786. private _useEnergyConservation;
  53787. /**
  53788. * Defines if the material uses energy conservation.
  53789. */
  53790. useEnergyConservation: boolean;
  53791. private _useSmithVisibilityHeightCorrelated;
  53792. /**
  53793. * LEGACY Mode set to false
  53794. * Defines if the material uses height smith correlated visibility term.
  53795. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  53796. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  53797. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  53798. * Not relying on height correlated will also disable energy conservation.
  53799. */
  53800. useSmithVisibilityHeightCorrelated: boolean;
  53801. private _useSphericalHarmonics;
  53802. /**
  53803. * LEGACY Mode set to false
  53804. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  53805. * diffuse part of the IBL.
  53806. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  53807. * to the ground truth.
  53808. */
  53809. useSphericalHarmonics: boolean;
  53810. private _useSpecularGlossinessInputEnergyConservation;
  53811. /**
  53812. * Defines if the material uses energy conservation, when the specular workflow is active.
  53813. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  53814. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  53815. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  53816. */
  53817. useSpecularGlossinessInputEnergyConservation: boolean;
  53818. /** @hidden */
  53819. private _internalMarkAllSubMeshesAsMiscDirty;
  53820. /** @hidden */
  53821. _markAllSubMeshesAsMiscDirty(): void;
  53822. /**
  53823. * Instantiate a new istance of clear coat configuration.
  53824. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  53825. */
  53826. constructor(markAllSubMeshesAsMiscDirty: () => void);
  53827. /**
  53828. * Checks to see if a texture is used in the material.
  53829. * @param defines the list of "defines" to update.
  53830. */
  53831. prepareDefines(defines: IMaterialBRDFDefines): void;
  53832. /**
  53833. * Get the current class name of the texture useful for serialization or dynamic coding.
  53834. * @returns "PBRClearCoatConfiguration"
  53835. */
  53836. getClassName(): string;
  53837. /**
  53838. * Makes a duplicate of the current configuration into another one.
  53839. * @param brdfConfiguration define the config where to copy the info
  53840. */
  53841. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  53842. /**
  53843. * Serializes this BRDF configuration.
  53844. * @returns - An object with the serialized config.
  53845. */
  53846. serialize(): any;
  53847. /**
  53848. * Parses a anisotropy Configuration from a serialized object.
  53849. * @param source - Serialized object.
  53850. * @param scene Defines the scene we are parsing for
  53851. * @param rootUrl Defines the rootUrl to load from
  53852. */
  53853. parse(source: any, scene: Scene, rootUrl: string): void;
  53854. }
  53855. }
  53856. declare module BABYLON {
  53857. /**
  53858. * @hidden
  53859. */
  53860. export interface IMaterialSheenDefines {
  53861. SHEEN: boolean;
  53862. SHEEN_TEXTURE: boolean;
  53863. SHEEN_TEXTUREDIRECTUV: number;
  53864. SHEEN_LINKWITHALBEDO: boolean;
  53865. SHEEN_ROUGHNESS: boolean;
  53866. SHEEN_ALBEDOSCALING: boolean;
  53867. /** @hidden */
  53868. _areTexturesDirty: boolean;
  53869. }
  53870. /**
  53871. * Define the code related to the Sheen parameters of the pbr material.
  53872. */
  53873. export class PBRSheenConfiguration {
  53874. private _isEnabled;
  53875. /**
  53876. * Defines if the material uses sheen.
  53877. */
  53878. isEnabled: boolean;
  53879. private _linkSheenWithAlbedo;
  53880. /**
  53881. * Defines if the sheen is linked to the sheen color.
  53882. */
  53883. linkSheenWithAlbedo: boolean;
  53884. /**
  53885. * Defines the sheen intensity.
  53886. */
  53887. intensity: number;
  53888. /**
  53889. * Defines the sheen color.
  53890. */
  53891. color: Color3;
  53892. private _texture;
  53893. /**
  53894. * Stores the sheen tint values in a texture.
  53895. * rgb is tint
  53896. * a is a intensity
  53897. */
  53898. texture: Nullable<BaseTexture>;
  53899. private _roughness;
  53900. /**
  53901. * Defines the sheen roughness.
  53902. * It is not taken into account if linkSheenWithAlbedo is true.
  53903. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  53904. */
  53905. roughness: Nullable<number>;
  53906. private _albedoScaling;
  53907. /**
  53908. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  53909. * It allows the strength of the sheen effect to not depend on the base color of the material,
  53910. * making it easier to setup and tweak the effect
  53911. */
  53912. albedoScaling: boolean;
  53913. /** @hidden */
  53914. private _internalMarkAllSubMeshesAsTexturesDirty;
  53915. /** @hidden */
  53916. _markAllSubMeshesAsTexturesDirty(): void;
  53917. /**
  53918. * Instantiate a new istance of clear coat configuration.
  53919. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53920. */
  53921. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53922. /**
  53923. * Specifies that the submesh is ready to be used.
  53924. * @param defines the list of "defines" to update.
  53925. * @param scene defines the scene the material belongs to.
  53926. * @returns - boolean indicating that the submesh is ready or not.
  53927. */
  53928. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  53929. /**
  53930. * Checks to see if a texture is used in the material.
  53931. * @param defines the list of "defines" to update.
  53932. * @param scene defines the scene the material belongs to.
  53933. */
  53934. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  53935. /**
  53936. * Binds the material data.
  53937. * @param uniformBuffer defines the Uniform buffer to fill in.
  53938. * @param scene defines the scene the material belongs to.
  53939. * @param isFrozen defines wether the material is frozen or not.
  53940. */
  53941. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  53942. /**
  53943. * Checks to see if a texture is used in the material.
  53944. * @param texture - Base texture to use.
  53945. * @returns - Boolean specifying if a texture is used in the material.
  53946. */
  53947. hasTexture(texture: BaseTexture): boolean;
  53948. /**
  53949. * Returns an array of the actively used textures.
  53950. * @param activeTextures Array of BaseTextures
  53951. */
  53952. getActiveTextures(activeTextures: BaseTexture[]): void;
  53953. /**
  53954. * Returns the animatable textures.
  53955. * @param animatables Array of animatable textures.
  53956. */
  53957. getAnimatables(animatables: IAnimatable[]): void;
  53958. /**
  53959. * Disposes the resources of the material.
  53960. * @param forceDisposeTextures - Forces the disposal of all textures.
  53961. */
  53962. dispose(forceDisposeTextures?: boolean): void;
  53963. /**
  53964. * Get the current class name of the texture useful for serialization or dynamic coding.
  53965. * @returns "PBRSheenConfiguration"
  53966. */
  53967. getClassName(): string;
  53968. /**
  53969. * Add fallbacks to the effect fallbacks list.
  53970. * @param defines defines the Base texture to use.
  53971. * @param fallbacks defines the current fallback list.
  53972. * @param currentRank defines the current fallback rank.
  53973. * @returns the new fallback rank.
  53974. */
  53975. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53976. /**
  53977. * Add the required uniforms to the current list.
  53978. * @param uniforms defines the current uniform list.
  53979. */
  53980. static AddUniforms(uniforms: string[]): void;
  53981. /**
  53982. * Add the required uniforms to the current buffer.
  53983. * @param uniformBuffer defines the current uniform buffer.
  53984. */
  53985. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53986. /**
  53987. * Add the required samplers to the current list.
  53988. * @param samplers defines the current sampler list.
  53989. */
  53990. static AddSamplers(samplers: string[]): void;
  53991. /**
  53992. * Makes a duplicate of the current configuration into another one.
  53993. * @param sheenConfiguration define the config where to copy the info
  53994. */
  53995. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53996. /**
  53997. * Serializes this BRDF configuration.
  53998. * @returns - An object with the serialized config.
  53999. */
  54000. serialize(): any;
  54001. /**
  54002. * Parses a anisotropy Configuration from a serialized object.
  54003. * @param source - Serialized object.
  54004. * @param scene Defines the scene we are parsing for
  54005. * @param rootUrl Defines the rootUrl to load from
  54006. */
  54007. parse(source: any, scene: Scene, rootUrl: string): void;
  54008. }
  54009. }
  54010. declare module BABYLON {
  54011. /**
  54012. * @hidden
  54013. */
  54014. export interface IMaterialSubSurfaceDefines {
  54015. SUBSURFACE: boolean;
  54016. SS_REFRACTION: boolean;
  54017. SS_TRANSLUCENCY: boolean;
  54018. SS_SCATERRING: boolean;
  54019. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54020. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54021. SS_REFRACTIONMAP_3D: boolean;
  54022. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54023. SS_LODINREFRACTIONALPHA: boolean;
  54024. SS_GAMMAREFRACTION: boolean;
  54025. SS_RGBDREFRACTION: boolean;
  54026. SS_LINEARSPECULARREFRACTION: boolean;
  54027. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54028. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54029. /** @hidden */
  54030. _areTexturesDirty: boolean;
  54031. }
  54032. /**
  54033. * Define the code related to the sub surface parameters of the pbr material.
  54034. */
  54035. export class PBRSubSurfaceConfiguration {
  54036. private _isRefractionEnabled;
  54037. /**
  54038. * Defines if the refraction is enabled in the material.
  54039. */
  54040. isRefractionEnabled: boolean;
  54041. private _isTranslucencyEnabled;
  54042. /**
  54043. * Defines if the translucency is enabled in the material.
  54044. */
  54045. isTranslucencyEnabled: boolean;
  54046. private _isScatteringEnabled;
  54047. /**
  54048. * Defines the refraction intensity of the material.
  54049. * The refraction when enabled replaces the Diffuse part of the material.
  54050. * The intensity helps transitionning between diffuse and refraction.
  54051. */
  54052. refractionIntensity: number;
  54053. /**
  54054. * Defines the translucency intensity of the material.
  54055. * When translucency has been enabled, this defines how much of the "translucency"
  54056. * is addded to the diffuse part of the material.
  54057. */
  54058. translucencyIntensity: number;
  54059. /**
  54060. * Defines the scattering intensity of the material.
  54061. * When scattering has been enabled, this defines how much of the "scattered light"
  54062. * is addded to the diffuse part of the material.
  54063. */
  54064. scatteringIntensity: number;
  54065. private _thicknessTexture;
  54066. /**
  54067. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54068. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54069. * 0 would mean minimumThickness
  54070. * 1 would mean maximumThickness
  54071. * The other channels might be use as a mask to vary the different effects intensity.
  54072. */
  54073. thicknessTexture: Nullable<BaseTexture>;
  54074. private _refractionTexture;
  54075. /**
  54076. * Defines the texture to use for refraction.
  54077. */
  54078. refractionTexture: Nullable<BaseTexture>;
  54079. private _indexOfRefraction;
  54080. /**
  54081. * Index of refraction of the material base layer.
  54082. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54083. *
  54084. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54085. *
  54086. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54087. */
  54088. indexOfRefraction: number;
  54089. private _invertRefractionY;
  54090. /**
  54091. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54092. */
  54093. invertRefractionY: boolean;
  54094. private _linkRefractionWithTransparency;
  54095. /**
  54096. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54097. * Materials half opaque for instance using refraction could benefit from this control.
  54098. */
  54099. linkRefractionWithTransparency: boolean;
  54100. /**
  54101. * Defines the minimum thickness stored in the thickness map.
  54102. * If no thickness map is defined, this value will be used to simulate thickness.
  54103. */
  54104. minimumThickness: number;
  54105. /**
  54106. * Defines the maximum thickness stored in the thickness map.
  54107. */
  54108. maximumThickness: number;
  54109. /**
  54110. * Defines the volume tint of the material.
  54111. * This is used for both translucency and scattering.
  54112. */
  54113. tintColor: Color3;
  54114. /**
  54115. * Defines the distance at which the tint color should be found in the media.
  54116. * This is used for refraction only.
  54117. */
  54118. tintColorAtDistance: number;
  54119. /**
  54120. * Defines how far each channel transmit through the media.
  54121. * It is defined as a color to simplify it selection.
  54122. */
  54123. diffusionDistance: Color3;
  54124. private _useMaskFromThicknessTexture;
  54125. /**
  54126. * Stores the intensity of the different subsurface effects in the thickness texture.
  54127. * * the green channel is the translucency intensity.
  54128. * * the blue channel is the scattering intensity.
  54129. * * the alpha channel is the refraction intensity.
  54130. */
  54131. useMaskFromThicknessTexture: boolean;
  54132. /** @hidden */
  54133. private _internalMarkAllSubMeshesAsTexturesDirty;
  54134. /** @hidden */
  54135. _markAllSubMeshesAsTexturesDirty(): void;
  54136. /**
  54137. * Instantiate a new istance of sub surface configuration.
  54138. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54139. */
  54140. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54141. /**
  54142. * Gets wehter the submesh is ready to be used or not.
  54143. * @param defines the list of "defines" to update.
  54144. * @param scene defines the scene the material belongs to.
  54145. * @returns - boolean indicating that the submesh is ready or not.
  54146. */
  54147. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54148. /**
  54149. * Checks to see if a texture is used in the material.
  54150. * @param defines the list of "defines" to update.
  54151. * @param scene defines the scene to the material belongs to.
  54152. */
  54153. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54154. /**
  54155. * Binds the material data.
  54156. * @param uniformBuffer defines the Uniform buffer to fill in.
  54157. * @param scene defines the scene the material belongs to.
  54158. * @param engine defines the engine the material belongs to.
  54159. * @param isFrozen defines whether the material is frozen or not.
  54160. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54161. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54162. */
  54163. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54164. /**
  54165. * Unbinds the material from the mesh.
  54166. * @param activeEffect defines the effect that should be unbound from.
  54167. * @returns true if unbound, otherwise false
  54168. */
  54169. unbind(activeEffect: Effect): boolean;
  54170. /**
  54171. * Returns the texture used for refraction or null if none is used.
  54172. * @param scene defines the scene the material belongs to.
  54173. * @returns - Refraction texture if present. If no refraction texture and refraction
  54174. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54175. */
  54176. private _getRefractionTexture;
  54177. /**
  54178. * Returns true if alpha blending should be disabled.
  54179. */
  54180. get disableAlphaBlending(): boolean;
  54181. /**
  54182. * Fills the list of render target textures.
  54183. * @param renderTargets the list of render targets to update
  54184. */
  54185. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54186. /**
  54187. * Checks to see if a texture is used in the material.
  54188. * @param texture - Base texture to use.
  54189. * @returns - Boolean specifying if a texture is used in the material.
  54190. */
  54191. hasTexture(texture: BaseTexture): boolean;
  54192. /**
  54193. * Gets a boolean indicating that current material needs to register RTT
  54194. * @returns true if this uses a render target otherwise false.
  54195. */
  54196. hasRenderTargetTextures(): boolean;
  54197. /**
  54198. * Returns an array of the actively used textures.
  54199. * @param activeTextures Array of BaseTextures
  54200. */
  54201. getActiveTextures(activeTextures: BaseTexture[]): void;
  54202. /**
  54203. * Returns the animatable textures.
  54204. * @param animatables Array of animatable textures.
  54205. */
  54206. getAnimatables(animatables: IAnimatable[]): void;
  54207. /**
  54208. * Disposes the resources of the material.
  54209. * @param forceDisposeTextures - Forces the disposal of all textures.
  54210. */
  54211. dispose(forceDisposeTextures?: boolean): void;
  54212. /**
  54213. * Get the current class name of the texture useful for serialization or dynamic coding.
  54214. * @returns "PBRSubSurfaceConfiguration"
  54215. */
  54216. getClassName(): string;
  54217. /**
  54218. * Add fallbacks to the effect fallbacks list.
  54219. * @param defines defines the Base texture to use.
  54220. * @param fallbacks defines the current fallback list.
  54221. * @param currentRank defines the current fallback rank.
  54222. * @returns the new fallback rank.
  54223. */
  54224. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54225. /**
  54226. * Add the required uniforms to the current list.
  54227. * @param uniforms defines the current uniform list.
  54228. */
  54229. static AddUniforms(uniforms: string[]): void;
  54230. /**
  54231. * Add the required samplers to the current list.
  54232. * @param samplers defines the current sampler list.
  54233. */
  54234. static AddSamplers(samplers: string[]): void;
  54235. /**
  54236. * Add the required uniforms to the current buffer.
  54237. * @param uniformBuffer defines the current uniform buffer.
  54238. */
  54239. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54240. /**
  54241. * Makes a duplicate of the current configuration into another one.
  54242. * @param configuration define the config where to copy the info
  54243. */
  54244. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54245. /**
  54246. * Serializes this Sub Surface configuration.
  54247. * @returns - An object with the serialized config.
  54248. */
  54249. serialize(): any;
  54250. /**
  54251. * Parses a anisotropy Configuration from a serialized object.
  54252. * @param source - Serialized object.
  54253. * @param scene Defines the scene we are parsing for
  54254. * @param rootUrl Defines the rootUrl to load from
  54255. */
  54256. parse(source: any, scene: Scene, rootUrl: string): void;
  54257. }
  54258. }
  54259. declare module BABYLON {
  54260. /** @hidden */
  54261. export var pbrFragmentDeclaration: {
  54262. name: string;
  54263. shader: string;
  54264. };
  54265. }
  54266. declare module BABYLON {
  54267. /** @hidden */
  54268. export var pbrUboDeclaration: {
  54269. name: string;
  54270. shader: string;
  54271. };
  54272. }
  54273. declare module BABYLON {
  54274. /** @hidden */
  54275. export var pbrFragmentExtraDeclaration: {
  54276. name: string;
  54277. shader: string;
  54278. };
  54279. }
  54280. declare module BABYLON {
  54281. /** @hidden */
  54282. export var pbrFragmentSamplersDeclaration: {
  54283. name: string;
  54284. shader: string;
  54285. };
  54286. }
  54287. declare module BABYLON {
  54288. /** @hidden */
  54289. export var importanceSampling: {
  54290. name: string;
  54291. shader: string;
  54292. };
  54293. }
  54294. declare module BABYLON {
  54295. /** @hidden */
  54296. export var pbrHelperFunctions: {
  54297. name: string;
  54298. shader: string;
  54299. };
  54300. }
  54301. declare module BABYLON {
  54302. /** @hidden */
  54303. export var harmonicsFunctions: {
  54304. name: string;
  54305. shader: string;
  54306. };
  54307. }
  54308. declare module BABYLON {
  54309. /** @hidden */
  54310. export var pbrDirectLightingSetupFunctions: {
  54311. name: string;
  54312. shader: string;
  54313. };
  54314. }
  54315. declare module BABYLON {
  54316. /** @hidden */
  54317. export var pbrDirectLightingFalloffFunctions: {
  54318. name: string;
  54319. shader: string;
  54320. };
  54321. }
  54322. declare module BABYLON {
  54323. /** @hidden */
  54324. export var pbrBRDFFunctions: {
  54325. name: string;
  54326. shader: string;
  54327. };
  54328. }
  54329. declare module BABYLON {
  54330. /** @hidden */
  54331. export var hdrFilteringFunctions: {
  54332. name: string;
  54333. shader: string;
  54334. };
  54335. }
  54336. declare module BABYLON {
  54337. /** @hidden */
  54338. export var pbrDirectLightingFunctions: {
  54339. name: string;
  54340. shader: string;
  54341. };
  54342. }
  54343. declare module BABYLON {
  54344. /** @hidden */
  54345. export var pbrIBLFunctions: {
  54346. name: string;
  54347. shader: string;
  54348. };
  54349. }
  54350. declare module BABYLON {
  54351. /** @hidden */
  54352. export var pbrBlockAlbedoOpacity: {
  54353. name: string;
  54354. shader: string;
  54355. };
  54356. }
  54357. declare module BABYLON {
  54358. /** @hidden */
  54359. export var pbrBlockReflectivity: {
  54360. name: string;
  54361. shader: string;
  54362. };
  54363. }
  54364. declare module BABYLON {
  54365. /** @hidden */
  54366. export var pbrBlockAmbientOcclusion: {
  54367. name: string;
  54368. shader: string;
  54369. };
  54370. }
  54371. declare module BABYLON {
  54372. /** @hidden */
  54373. export var pbrBlockAlphaFresnel: {
  54374. name: string;
  54375. shader: string;
  54376. };
  54377. }
  54378. declare module BABYLON {
  54379. /** @hidden */
  54380. export var pbrBlockAnisotropic: {
  54381. name: string;
  54382. shader: string;
  54383. };
  54384. }
  54385. declare module BABYLON {
  54386. /** @hidden */
  54387. export var pbrBlockReflection: {
  54388. name: string;
  54389. shader: string;
  54390. };
  54391. }
  54392. declare module BABYLON {
  54393. /** @hidden */
  54394. export var pbrBlockSheen: {
  54395. name: string;
  54396. shader: string;
  54397. };
  54398. }
  54399. declare module BABYLON {
  54400. /** @hidden */
  54401. export var pbrBlockClearcoat: {
  54402. name: string;
  54403. shader: string;
  54404. };
  54405. }
  54406. declare module BABYLON {
  54407. /** @hidden */
  54408. export var pbrBlockSubSurface: {
  54409. name: string;
  54410. shader: string;
  54411. };
  54412. }
  54413. declare module BABYLON {
  54414. /** @hidden */
  54415. export var pbrBlockNormalGeometric: {
  54416. name: string;
  54417. shader: string;
  54418. };
  54419. }
  54420. declare module BABYLON {
  54421. /** @hidden */
  54422. export var pbrBlockNormalFinal: {
  54423. name: string;
  54424. shader: string;
  54425. };
  54426. }
  54427. declare module BABYLON {
  54428. /** @hidden */
  54429. export var pbrBlockGeometryInfo: {
  54430. name: string;
  54431. shader: string;
  54432. };
  54433. }
  54434. declare module BABYLON {
  54435. /** @hidden */
  54436. export var pbrBlockReflectance0: {
  54437. name: string;
  54438. shader: string;
  54439. };
  54440. }
  54441. declare module BABYLON {
  54442. /** @hidden */
  54443. export var pbrBlockReflectance: {
  54444. name: string;
  54445. shader: string;
  54446. };
  54447. }
  54448. declare module BABYLON {
  54449. /** @hidden */
  54450. export var pbrBlockDirectLighting: {
  54451. name: string;
  54452. shader: string;
  54453. };
  54454. }
  54455. declare module BABYLON {
  54456. /** @hidden */
  54457. export var pbrBlockFinalLitComponents: {
  54458. name: string;
  54459. shader: string;
  54460. };
  54461. }
  54462. declare module BABYLON {
  54463. /** @hidden */
  54464. export var pbrBlockFinalUnlitComponents: {
  54465. name: string;
  54466. shader: string;
  54467. };
  54468. }
  54469. declare module BABYLON {
  54470. /** @hidden */
  54471. export var pbrBlockFinalColorComposition: {
  54472. name: string;
  54473. shader: string;
  54474. };
  54475. }
  54476. declare module BABYLON {
  54477. /** @hidden */
  54478. export var pbrBlockImageProcessing: {
  54479. name: string;
  54480. shader: string;
  54481. };
  54482. }
  54483. declare module BABYLON {
  54484. /** @hidden */
  54485. export var pbrDebug: {
  54486. name: string;
  54487. shader: string;
  54488. };
  54489. }
  54490. declare module BABYLON {
  54491. /** @hidden */
  54492. export var pbrPixelShader: {
  54493. name: string;
  54494. shader: string;
  54495. };
  54496. }
  54497. declare module BABYLON {
  54498. /** @hidden */
  54499. export var pbrVertexDeclaration: {
  54500. name: string;
  54501. shader: string;
  54502. };
  54503. }
  54504. declare module BABYLON {
  54505. /** @hidden */
  54506. export var pbrVertexShader: {
  54507. name: string;
  54508. shader: string;
  54509. };
  54510. }
  54511. declare module BABYLON {
  54512. /**
  54513. * Manages the defines for the PBR Material.
  54514. * @hidden
  54515. */
  54516. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  54517. PBR: boolean;
  54518. NUM_SAMPLES: string;
  54519. REALTIME_FILTERING: boolean;
  54520. MAINUV1: boolean;
  54521. MAINUV2: boolean;
  54522. UV1: boolean;
  54523. UV2: boolean;
  54524. ALBEDO: boolean;
  54525. GAMMAALBEDO: boolean;
  54526. ALBEDODIRECTUV: number;
  54527. VERTEXCOLOR: boolean;
  54528. AMBIENT: boolean;
  54529. AMBIENTDIRECTUV: number;
  54530. AMBIENTINGRAYSCALE: boolean;
  54531. OPACITY: boolean;
  54532. VERTEXALPHA: boolean;
  54533. OPACITYDIRECTUV: number;
  54534. OPACITYRGB: boolean;
  54535. ALPHATEST: boolean;
  54536. DEPTHPREPASS: boolean;
  54537. ALPHABLEND: boolean;
  54538. ALPHAFROMALBEDO: boolean;
  54539. ALPHATESTVALUE: string;
  54540. SPECULAROVERALPHA: boolean;
  54541. RADIANCEOVERALPHA: boolean;
  54542. ALPHAFRESNEL: boolean;
  54543. LINEARALPHAFRESNEL: boolean;
  54544. PREMULTIPLYALPHA: boolean;
  54545. EMISSIVE: boolean;
  54546. EMISSIVEDIRECTUV: number;
  54547. REFLECTIVITY: boolean;
  54548. REFLECTIVITYDIRECTUV: number;
  54549. SPECULARTERM: boolean;
  54550. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54551. MICROSURFACEAUTOMATIC: boolean;
  54552. LODBASEDMICROSFURACE: boolean;
  54553. MICROSURFACEMAP: boolean;
  54554. MICROSURFACEMAPDIRECTUV: number;
  54555. METALLICWORKFLOW: boolean;
  54556. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54557. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54558. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54559. AOSTOREINMETALMAPRED: boolean;
  54560. METALLIC_REFLECTANCE: boolean;
  54561. METALLIC_REFLECTANCEDIRECTUV: number;
  54562. ENVIRONMENTBRDF: boolean;
  54563. ENVIRONMENTBRDF_RGBD: boolean;
  54564. NORMAL: boolean;
  54565. TANGENT: boolean;
  54566. BUMP: boolean;
  54567. BUMPDIRECTUV: number;
  54568. OBJECTSPACE_NORMALMAP: boolean;
  54569. PARALLAX: boolean;
  54570. PARALLAXOCCLUSION: boolean;
  54571. NORMALXYSCALE: boolean;
  54572. LIGHTMAP: boolean;
  54573. LIGHTMAPDIRECTUV: number;
  54574. USELIGHTMAPASSHADOWMAP: boolean;
  54575. GAMMALIGHTMAP: boolean;
  54576. RGBDLIGHTMAP: boolean;
  54577. REFLECTION: boolean;
  54578. REFLECTIONMAP_3D: boolean;
  54579. REFLECTIONMAP_SPHERICAL: boolean;
  54580. REFLECTIONMAP_PLANAR: boolean;
  54581. REFLECTIONMAP_CUBIC: boolean;
  54582. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  54583. REFLECTIONMAP_PROJECTION: boolean;
  54584. REFLECTIONMAP_SKYBOX: boolean;
  54585. REFLECTIONMAP_EXPLICIT: boolean;
  54586. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  54587. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  54588. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  54589. INVERTCUBICMAP: boolean;
  54590. USESPHERICALFROMREFLECTIONMAP: boolean;
  54591. USEIRRADIANCEMAP: boolean;
  54592. SPHERICAL_HARMONICS: boolean;
  54593. USESPHERICALINVERTEX: boolean;
  54594. REFLECTIONMAP_OPPOSITEZ: boolean;
  54595. LODINREFLECTIONALPHA: boolean;
  54596. GAMMAREFLECTION: boolean;
  54597. RGBDREFLECTION: boolean;
  54598. LINEARSPECULARREFLECTION: boolean;
  54599. RADIANCEOCCLUSION: boolean;
  54600. HORIZONOCCLUSION: boolean;
  54601. INSTANCES: boolean;
  54602. THIN_INSTANCES: boolean;
  54603. NUM_BONE_INFLUENCERS: number;
  54604. BonesPerMesh: number;
  54605. BONETEXTURE: boolean;
  54606. NONUNIFORMSCALING: boolean;
  54607. MORPHTARGETS: boolean;
  54608. MORPHTARGETS_NORMAL: boolean;
  54609. MORPHTARGETS_TANGENT: boolean;
  54610. MORPHTARGETS_UV: boolean;
  54611. NUM_MORPH_INFLUENCERS: number;
  54612. IMAGEPROCESSING: boolean;
  54613. VIGNETTE: boolean;
  54614. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54615. VIGNETTEBLENDMODEOPAQUE: boolean;
  54616. TONEMAPPING: boolean;
  54617. TONEMAPPING_ACES: boolean;
  54618. CONTRAST: boolean;
  54619. COLORCURVES: boolean;
  54620. COLORGRADING: boolean;
  54621. COLORGRADING3D: boolean;
  54622. SAMPLER3DGREENDEPTH: boolean;
  54623. SAMPLER3DBGRMAP: boolean;
  54624. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54625. EXPOSURE: boolean;
  54626. MULTIVIEW: boolean;
  54627. USEPHYSICALLIGHTFALLOFF: boolean;
  54628. USEGLTFLIGHTFALLOFF: boolean;
  54629. TWOSIDEDLIGHTING: boolean;
  54630. SHADOWFLOAT: boolean;
  54631. CLIPPLANE: boolean;
  54632. CLIPPLANE2: boolean;
  54633. CLIPPLANE3: boolean;
  54634. CLIPPLANE4: boolean;
  54635. CLIPPLANE5: boolean;
  54636. CLIPPLANE6: boolean;
  54637. POINTSIZE: boolean;
  54638. FOG: boolean;
  54639. LOGARITHMICDEPTH: boolean;
  54640. FORCENORMALFORWARD: boolean;
  54641. SPECULARAA: boolean;
  54642. CLEARCOAT: boolean;
  54643. CLEARCOAT_DEFAULTIOR: boolean;
  54644. CLEARCOAT_TEXTURE: boolean;
  54645. CLEARCOAT_TEXTUREDIRECTUV: number;
  54646. CLEARCOAT_BUMP: boolean;
  54647. CLEARCOAT_BUMPDIRECTUV: number;
  54648. CLEARCOAT_TINT: boolean;
  54649. CLEARCOAT_TINT_TEXTURE: boolean;
  54650. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54651. ANISOTROPIC: boolean;
  54652. ANISOTROPIC_TEXTURE: boolean;
  54653. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54654. BRDF_V_HEIGHT_CORRELATED: boolean;
  54655. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54656. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54657. SHEEN: boolean;
  54658. SHEEN_TEXTURE: boolean;
  54659. SHEEN_TEXTUREDIRECTUV: number;
  54660. SHEEN_LINKWITHALBEDO: boolean;
  54661. SHEEN_ROUGHNESS: boolean;
  54662. SHEEN_ALBEDOSCALING: boolean;
  54663. SUBSURFACE: boolean;
  54664. SS_REFRACTION: boolean;
  54665. SS_TRANSLUCENCY: boolean;
  54666. SS_SCATERRING: boolean;
  54667. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54668. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54669. SS_REFRACTIONMAP_3D: boolean;
  54670. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54671. SS_LODINREFRACTIONALPHA: boolean;
  54672. SS_GAMMAREFRACTION: boolean;
  54673. SS_RGBDREFRACTION: boolean;
  54674. SS_LINEARSPECULARREFRACTION: boolean;
  54675. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54676. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54677. UNLIT: boolean;
  54678. DEBUGMODE: number;
  54679. /**
  54680. * Initializes the PBR Material defines.
  54681. */
  54682. constructor();
  54683. /**
  54684. * Resets the PBR Material defines.
  54685. */
  54686. reset(): void;
  54687. }
  54688. /**
  54689. * The Physically based material base class of BJS.
  54690. *
  54691. * This offers the main features of a standard PBR material.
  54692. * For more information, please refer to the documentation :
  54693. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54694. */
  54695. export abstract class PBRBaseMaterial extends PushMaterial {
  54696. /**
  54697. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54698. */
  54699. static readonly PBRMATERIAL_OPAQUE: number;
  54700. /**
  54701. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54702. */
  54703. static readonly PBRMATERIAL_ALPHATEST: number;
  54704. /**
  54705. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54706. */
  54707. static readonly PBRMATERIAL_ALPHABLEND: number;
  54708. /**
  54709. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54710. * They are also discarded below the alpha cutoff threshold to improve performances.
  54711. */
  54712. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54713. /**
  54714. * Defines the default value of how much AO map is occluding the analytical lights
  54715. * (point spot...).
  54716. */
  54717. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54718. /**
  54719. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  54720. */
  54721. static readonly LIGHTFALLOFF_PHYSICAL: number;
  54722. /**
  54723. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  54724. * to enhance interoperability with other engines.
  54725. */
  54726. static readonly LIGHTFALLOFF_GLTF: number;
  54727. /**
  54728. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  54729. * to enhance interoperability with other materials.
  54730. */
  54731. static readonly LIGHTFALLOFF_STANDARD: number;
  54732. /**
  54733. * Intensity of the direct lights e.g. the four lights available in your scene.
  54734. * This impacts both the direct diffuse and specular highlights.
  54735. */
  54736. protected _directIntensity: number;
  54737. /**
  54738. * Intensity of the emissive part of the material.
  54739. * This helps controlling the emissive effect without modifying the emissive color.
  54740. */
  54741. protected _emissiveIntensity: number;
  54742. /**
  54743. * Intensity of the environment e.g. how much the environment will light the object
  54744. * either through harmonics for rough material or through the refelction for shiny ones.
  54745. */
  54746. protected _environmentIntensity: number;
  54747. /**
  54748. * This is a special control allowing the reduction of the specular highlights coming from the
  54749. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54750. */
  54751. protected _specularIntensity: number;
  54752. /**
  54753. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  54754. */
  54755. private _lightingInfos;
  54756. /**
  54757. * Debug Control allowing disabling the bump map on this material.
  54758. */
  54759. protected _disableBumpMap: boolean;
  54760. /**
  54761. * AKA Diffuse Texture in standard nomenclature.
  54762. */
  54763. protected _albedoTexture: Nullable<BaseTexture>;
  54764. /**
  54765. * AKA Occlusion Texture in other nomenclature.
  54766. */
  54767. protected _ambientTexture: Nullable<BaseTexture>;
  54768. /**
  54769. * AKA Occlusion Texture Intensity in other nomenclature.
  54770. */
  54771. protected _ambientTextureStrength: number;
  54772. /**
  54773. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54774. * 1 means it completely occludes it
  54775. * 0 mean it has no impact
  54776. */
  54777. protected _ambientTextureImpactOnAnalyticalLights: number;
  54778. /**
  54779. * Stores the alpha values in a texture.
  54780. */
  54781. protected _opacityTexture: Nullable<BaseTexture>;
  54782. /**
  54783. * Stores the reflection values in a texture.
  54784. */
  54785. protected _reflectionTexture: Nullable<BaseTexture>;
  54786. /**
  54787. * Stores the emissive values in a texture.
  54788. */
  54789. protected _emissiveTexture: Nullable<BaseTexture>;
  54790. /**
  54791. * AKA Specular texture in other nomenclature.
  54792. */
  54793. protected _reflectivityTexture: Nullable<BaseTexture>;
  54794. /**
  54795. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54796. */
  54797. protected _metallicTexture: Nullable<BaseTexture>;
  54798. /**
  54799. * Specifies the metallic scalar of the metallic/roughness workflow.
  54800. * Can also be used to scale the metalness values of the metallic texture.
  54801. */
  54802. protected _metallic: Nullable<number>;
  54803. /**
  54804. * Specifies the roughness scalar of the metallic/roughness workflow.
  54805. * Can also be used to scale the roughness values of the metallic texture.
  54806. */
  54807. protected _roughness: Nullable<number>;
  54808. /**
  54809. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  54810. * By default the indexOfrefraction is used to compute F0;
  54811. *
  54812. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  54813. *
  54814. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  54815. * F90 = metallicReflectanceColor;
  54816. */
  54817. protected _metallicF0Factor: number;
  54818. /**
  54819. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  54820. * By default the F90 is always 1;
  54821. *
  54822. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  54823. *
  54824. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  54825. * F90 = metallicReflectanceColor;
  54826. */
  54827. protected _metallicReflectanceColor: Color3;
  54828. /**
  54829. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  54830. * This is multiply against the scalar values defined in the material.
  54831. */
  54832. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  54833. /**
  54834. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54835. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54836. */
  54837. protected _microSurfaceTexture: Nullable<BaseTexture>;
  54838. /**
  54839. * Stores surface normal data used to displace a mesh in a texture.
  54840. */
  54841. protected _bumpTexture: Nullable<BaseTexture>;
  54842. /**
  54843. * Stores the pre-calculated light information of a mesh in a texture.
  54844. */
  54845. protected _lightmapTexture: Nullable<BaseTexture>;
  54846. /**
  54847. * The color of a material in ambient lighting.
  54848. */
  54849. protected _ambientColor: Color3;
  54850. /**
  54851. * AKA Diffuse Color in other nomenclature.
  54852. */
  54853. protected _albedoColor: Color3;
  54854. /**
  54855. * AKA Specular Color in other nomenclature.
  54856. */
  54857. protected _reflectivityColor: Color3;
  54858. /**
  54859. * The color applied when light is reflected from a material.
  54860. */
  54861. protected _reflectionColor: Color3;
  54862. /**
  54863. * The color applied when light is emitted from a material.
  54864. */
  54865. protected _emissiveColor: Color3;
  54866. /**
  54867. * AKA Glossiness in other nomenclature.
  54868. */
  54869. protected _microSurface: number;
  54870. /**
  54871. * Specifies that the material will use the light map as a show map.
  54872. */
  54873. protected _useLightmapAsShadowmap: boolean;
  54874. /**
  54875. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54876. * makes the reflect vector face the model (under horizon).
  54877. */
  54878. protected _useHorizonOcclusion: boolean;
  54879. /**
  54880. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54881. * too much the area relying on ambient texture to define their ambient occlusion.
  54882. */
  54883. protected _useRadianceOcclusion: boolean;
  54884. /**
  54885. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54886. */
  54887. protected _useAlphaFromAlbedoTexture: boolean;
  54888. /**
  54889. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  54890. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54891. */
  54892. protected _useSpecularOverAlpha: boolean;
  54893. /**
  54894. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54895. */
  54896. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54897. /**
  54898. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54899. */
  54900. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  54901. /**
  54902. * Specifies if the metallic texture contains the roughness information in its green channel.
  54903. */
  54904. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54905. /**
  54906. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54907. */
  54908. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54909. /**
  54910. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54911. */
  54912. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54913. /**
  54914. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54915. */
  54916. protected _useAmbientInGrayScale: boolean;
  54917. /**
  54918. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54919. * The material will try to infer what glossiness each pixel should be.
  54920. */
  54921. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54922. /**
  54923. * Defines the falloff type used in this material.
  54924. * It by default is Physical.
  54925. */
  54926. protected _lightFalloff: number;
  54927. /**
  54928. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54929. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54930. */
  54931. protected _useRadianceOverAlpha: boolean;
  54932. /**
  54933. * Allows using an object space normal map (instead of tangent space).
  54934. */
  54935. protected _useObjectSpaceNormalMap: boolean;
  54936. /**
  54937. * Allows using the bump map in parallax mode.
  54938. */
  54939. protected _useParallax: boolean;
  54940. /**
  54941. * Allows using the bump map in parallax occlusion mode.
  54942. */
  54943. protected _useParallaxOcclusion: boolean;
  54944. /**
  54945. * Controls the scale bias of the parallax mode.
  54946. */
  54947. protected _parallaxScaleBias: number;
  54948. /**
  54949. * If sets to true, disables all the lights affecting the material.
  54950. */
  54951. protected _disableLighting: boolean;
  54952. /**
  54953. * Number of Simultaneous lights allowed on the material.
  54954. */
  54955. protected _maxSimultaneousLights: number;
  54956. /**
  54957. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54958. */
  54959. protected _invertNormalMapX: boolean;
  54960. /**
  54961. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54962. */
  54963. protected _invertNormalMapY: boolean;
  54964. /**
  54965. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54966. */
  54967. protected _twoSidedLighting: boolean;
  54968. /**
  54969. * Defines the alpha limits in alpha test mode.
  54970. */
  54971. protected _alphaCutOff: number;
  54972. /**
  54973. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54974. */
  54975. protected _forceAlphaTest: boolean;
  54976. /**
  54977. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54978. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54979. */
  54980. protected _useAlphaFresnel: boolean;
  54981. /**
  54982. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54983. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54984. */
  54985. protected _useLinearAlphaFresnel: boolean;
  54986. /**
  54987. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54988. * from cos thetav and roughness:
  54989. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54990. */
  54991. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54992. /**
  54993. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54994. */
  54995. protected _forceIrradianceInFragment: boolean;
  54996. private _realTimeFiltering;
  54997. /**
  54998. * Enables realtime filtering on the texture.
  54999. */
  55000. get realTimeFiltering(): boolean;
  55001. set realTimeFiltering(b: boolean);
  55002. private _realTimeFilteringQuality;
  55003. /**
  55004. * Quality switch for realtime filtering
  55005. */
  55006. get realTimeFilteringQuality(): number;
  55007. set realTimeFilteringQuality(n: number);
  55008. /**
  55009. * Force normal to face away from face.
  55010. */
  55011. protected _forceNormalForward: boolean;
  55012. /**
  55013. * Enables specular anti aliasing in the PBR shader.
  55014. * It will both interacts on the Geometry for analytical and IBL lighting.
  55015. * It also prefilter the roughness map based on the bump values.
  55016. */
  55017. protected _enableSpecularAntiAliasing: boolean;
  55018. /**
  55019. * Default configuration related to image processing available in the PBR Material.
  55020. */
  55021. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55022. /**
  55023. * Keep track of the image processing observer to allow dispose and replace.
  55024. */
  55025. private _imageProcessingObserver;
  55026. /**
  55027. * Attaches a new image processing configuration to the PBR Material.
  55028. * @param configuration
  55029. */
  55030. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55031. /**
  55032. * Stores the available render targets.
  55033. */
  55034. private _renderTargets;
  55035. /**
  55036. * Sets the global ambient color for the material used in lighting calculations.
  55037. */
  55038. private _globalAmbientColor;
  55039. /**
  55040. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55041. */
  55042. private _useLogarithmicDepth;
  55043. /**
  55044. * If set to true, no lighting calculations will be applied.
  55045. */
  55046. private _unlit;
  55047. private _debugMode;
  55048. /**
  55049. * @hidden
  55050. * This is reserved for the inspector.
  55051. * Defines the material debug mode.
  55052. * It helps seeing only some components of the material while troubleshooting.
  55053. */
  55054. debugMode: number;
  55055. /**
  55056. * @hidden
  55057. * This is reserved for the inspector.
  55058. * Specify from where on screen the debug mode should start.
  55059. * The value goes from -1 (full screen) to 1 (not visible)
  55060. * It helps with side by side comparison against the final render
  55061. * This defaults to -1
  55062. */
  55063. private debugLimit;
  55064. /**
  55065. * @hidden
  55066. * This is reserved for the inspector.
  55067. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55068. * You can use the factor to better multiply the final value.
  55069. */
  55070. private debugFactor;
  55071. /**
  55072. * Defines the clear coat layer parameters for the material.
  55073. */
  55074. readonly clearCoat: PBRClearCoatConfiguration;
  55075. /**
  55076. * Defines the anisotropic parameters for the material.
  55077. */
  55078. readonly anisotropy: PBRAnisotropicConfiguration;
  55079. /**
  55080. * Defines the BRDF parameters for the material.
  55081. */
  55082. readonly brdf: PBRBRDFConfiguration;
  55083. /**
  55084. * Defines the Sheen parameters for the material.
  55085. */
  55086. readonly sheen: PBRSheenConfiguration;
  55087. /**
  55088. * Defines the SubSurface parameters for the material.
  55089. */
  55090. readonly subSurface: PBRSubSurfaceConfiguration;
  55091. protected _rebuildInParallel: boolean;
  55092. /**
  55093. * Instantiates a new PBRMaterial instance.
  55094. *
  55095. * @param name The material name
  55096. * @param scene The scene the material will be use in.
  55097. */
  55098. constructor(name: string, scene: Scene);
  55099. /**
  55100. * Gets a boolean indicating that current material needs to register RTT
  55101. */
  55102. get hasRenderTargetTextures(): boolean;
  55103. /**
  55104. * Gets the name of the material class.
  55105. */
  55106. getClassName(): string;
  55107. /**
  55108. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55109. */
  55110. get useLogarithmicDepth(): boolean;
  55111. /**
  55112. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55113. */
  55114. set useLogarithmicDepth(value: boolean);
  55115. /**
  55116. * Returns true if alpha blending should be disabled.
  55117. */
  55118. protected get _disableAlphaBlending(): boolean;
  55119. /**
  55120. * Specifies whether or not this material should be rendered in alpha blend mode.
  55121. */
  55122. needAlphaBlending(): boolean;
  55123. /**
  55124. * Specifies whether or not this material should be rendered in alpha test mode.
  55125. */
  55126. needAlphaTesting(): boolean;
  55127. /**
  55128. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55129. */
  55130. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55131. /**
  55132. * Gets the texture used for the alpha test.
  55133. */
  55134. getAlphaTestTexture(): Nullable<BaseTexture>;
  55135. /**
  55136. * Specifies that the submesh is ready to be used.
  55137. * @param mesh - BJS mesh.
  55138. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55139. * @param useInstances - Specifies that instances should be used.
  55140. * @returns - boolean indicating that the submesh is ready or not.
  55141. */
  55142. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55143. /**
  55144. * Specifies if the material uses metallic roughness workflow.
  55145. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55146. */
  55147. isMetallicWorkflow(): boolean;
  55148. private _prepareEffect;
  55149. private _prepareDefines;
  55150. /**
  55151. * Force shader compilation
  55152. */
  55153. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55154. /**
  55155. * Initializes the uniform buffer layout for the shader.
  55156. */
  55157. buildUniformLayout(): void;
  55158. /**
  55159. * Unbinds the material from the mesh
  55160. */
  55161. unbind(): void;
  55162. /**
  55163. * Binds the submesh data.
  55164. * @param world - The world matrix.
  55165. * @param mesh - The BJS mesh.
  55166. * @param subMesh - A submesh of the BJS mesh.
  55167. */
  55168. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55169. /**
  55170. * Returns the animatable textures.
  55171. * @returns - Array of animatable textures.
  55172. */
  55173. getAnimatables(): IAnimatable[];
  55174. /**
  55175. * Returns the texture used for reflections.
  55176. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55177. */
  55178. private _getReflectionTexture;
  55179. /**
  55180. * Returns an array of the actively used textures.
  55181. * @returns - Array of BaseTextures
  55182. */
  55183. getActiveTextures(): BaseTexture[];
  55184. /**
  55185. * Checks to see if a texture is used in the material.
  55186. * @param texture - Base texture to use.
  55187. * @returns - Boolean specifying if a texture is used in the material.
  55188. */
  55189. hasTexture(texture: BaseTexture): boolean;
  55190. /**
  55191. * Disposes the resources of the material.
  55192. * @param forceDisposeEffect - Forces the disposal of effects.
  55193. * @param forceDisposeTextures - Forces the disposal of all textures.
  55194. */
  55195. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55196. }
  55197. }
  55198. declare module BABYLON {
  55199. /**
  55200. * The Physically based material of BJS.
  55201. *
  55202. * This offers the main features of a standard PBR material.
  55203. * For more information, please refer to the documentation :
  55204. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55205. */
  55206. export class PBRMaterial extends PBRBaseMaterial {
  55207. /**
  55208. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55209. */
  55210. static readonly PBRMATERIAL_OPAQUE: number;
  55211. /**
  55212. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55213. */
  55214. static readonly PBRMATERIAL_ALPHATEST: number;
  55215. /**
  55216. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55217. */
  55218. static readonly PBRMATERIAL_ALPHABLEND: number;
  55219. /**
  55220. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55221. * They are also discarded below the alpha cutoff threshold to improve performances.
  55222. */
  55223. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55224. /**
  55225. * Defines the default value of how much AO map is occluding the analytical lights
  55226. * (point spot...).
  55227. */
  55228. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55229. /**
  55230. * Intensity of the direct lights e.g. the four lights available in your scene.
  55231. * This impacts both the direct diffuse and specular highlights.
  55232. */
  55233. directIntensity: number;
  55234. /**
  55235. * Intensity of the emissive part of the material.
  55236. * This helps controlling the emissive effect without modifying the emissive color.
  55237. */
  55238. emissiveIntensity: number;
  55239. /**
  55240. * Intensity of the environment e.g. how much the environment will light the object
  55241. * either through harmonics for rough material or through the refelction for shiny ones.
  55242. */
  55243. environmentIntensity: number;
  55244. /**
  55245. * This is a special control allowing the reduction of the specular highlights coming from the
  55246. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55247. */
  55248. specularIntensity: number;
  55249. /**
  55250. * Debug Control allowing disabling the bump map on this material.
  55251. */
  55252. disableBumpMap: boolean;
  55253. /**
  55254. * AKA Diffuse Texture in standard nomenclature.
  55255. */
  55256. albedoTexture: BaseTexture;
  55257. /**
  55258. * AKA Occlusion Texture in other nomenclature.
  55259. */
  55260. ambientTexture: BaseTexture;
  55261. /**
  55262. * AKA Occlusion Texture Intensity in other nomenclature.
  55263. */
  55264. ambientTextureStrength: number;
  55265. /**
  55266. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55267. * 1 means it completely occludes it
  55268. * 0 mean it has no impact
  55269. */
  55270. ambientTextureImpactOnAnalyticalLights: number;
  55271. /**
  55272. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55273. */
  55274. opacityTexture: BaseTexture;
  55275. /**
  55276. * Stores the reflection values in a texture.
  55277. */
  55278. reflectionTexture: Nullable<BaseTexture>;
  55279. /**
  55280. * Stores the emissive values in a texture.
  55281. */
  55282. emissiveTexture: BaseTexture;
  55283. /**
  55284. * AKA Specular texture in other nomenclature.
  55285. */
  55286. reflectivityTexture: BaseTexture;
  55287. /**
  55288. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55289. */
  55290. metallicTexture: BaseTexture;
  55291. /**
  55292. * Specifies the metallic scalar of the metallic/roughness workflow.
  55293. * Can also be used to scale the metalness values of the metallic texture.
  55294. */
  55295. metallic: Nullable<number>;
  55296. /**
  55297. * Specifies the roughness scalar of the metallic/roughness workflow.
  55298. * Can also be used to scale the roughness values of the metallic texture.
  55299. */
  55300. roughness: Nullable<number>;
  55301. /**
  55302. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55303. * By default the indexOfrefraction is used to compute F0;
  55304. *
  55305. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55306. *
  55307. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55308. * F90 = metallicReflectanceColor;
  55309. */
  55310. metallicF0Factor: number;
  55311. /**
  55312. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55313. * By default the F90 is always 1;
  55314. *
  55315. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55316. *
  55317. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55318. * F90 = metallicReflectanceColor;
  55319. */
  55320. metallicReflectanceColor: Color3;
  55321. /**
  55322. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55323. * This is multiply against the scalar values defined in the material.
  55324. */
  55325. metallicReflectanceTexture: Nullable<BaseTexture>;
  55326. /**
  55327. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55328. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55329. */
  55330. microSurfaceTexture: BaseTexture;
  55331. /**
  55332. * Stores surface normal data used to displace a mesh in a texture.
  55333. */
  55334. bumpTexture: BaseTexture;
  55335. /**
  55336. * Stores the pre-calculated light information of a mesh in a texture.
  55337. */
  55338. lightmapTexture: BaseTexture;
  55339. /**
  55340. * Stores the refracted light information in a texture.
  55341. */
  55342. get refractionTexture(): Nullable<BaseTexture>;
  55343. set refractionTexture(value: Nullable<BaseTexture>);
  55344. /**
  55345. * The color of a material in ambient lighting.
  55346. */
  55347. ambientColor: Color3;
  55348. /**
  55349. * AKA Diffuse Color in other nomenclature.
  55350. */
  55351. albedoColor: Color3;
  55352. /**
  55353. * AKA Specular Color in other nomenclature.
  55354. */
  55355. reflectivityColor: Color3;
  55356. /**
  55357. * The color reflected from the material.
  55358. */
  55359. reflectionColor: Color3;
  55360. /**
  55361. * The color emitted from the material.
  55362. */
  55363. emissiveColor: Color3;
  55364. /**
  55365. * AKA Glossiness in other nomenclature.
  55366. */
  55367. microSurface: number;
  55368. /**
  55369. * Index of refraction of the material base layer.
  55370. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55371. *
  55372. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55373. *
  55374. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55375. */
  55376. get indexOfRefraction(): number;
  55377. set indexOfRefraction(value: number);
  55378. /**
  55379. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55380. */
  55381. get invertRefractionY(): boolean;
  55382. set invertRefractionY(value: boolean);
  55383. /**
  55384. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55385. * Materials half opaque for instance using refraction could benefit from this control.
  55386. */
  55387. get linkRefractionWithTransparency(): boolean;
  55388. set linkRefractionWithTransparency(value: boolean);
  55389. /**
  55390. * If true, the light map contains occlusion information instead of lighting info.
  55391. */
  55392. useLightmapAsShadowmap: boolean;
  55393. /**
  55394. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55395. */
  55396. useAlphaFromAlbedoTexture: boolean;
  55397. /**
  55398. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55399. */
  55400. forceAlphaTest: boolean;
  55401. /**
  55402. * Defines the alpha limits in alpha test mode.
  55403. */
  55404. alphaCutOff: number;
  55405. /**
  55406. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55407. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55408. */
  55409. useSpecularOverAlpha: boolean;
  55410. /**
  55411. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55412. */
  55413. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55414. /**
  55415. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55416. */
  55417. useRoughnessFromMetallicTextureAlpha: boolean;
  55418. /**
  55419. * Specifies if the metallic texture contains the roughness information in its green channel.
  55420. */
  55421. useRoughnessFromMetallicTextureGreen: boolean;
  55422. /**
  55423. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55424. */
  55425. useMetallnessFromMetallicTextureBlue: boolean;
  55426. /**
  55427. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55428. */
  55429. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55430. /**
  55431. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55432. */
  55433. useAmbientInGrayScale: boolean;
  55434. /**
  55435. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55436. * The material will try to infer what glossiness each pixel should be.
  55437. */
  55438. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55439. /**
  55440. * BJS is using an harcoded light falloff based on a manually sets up range.
  55441. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55442. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55443. */
  55444. get usePhysicalLightFalloff(): boolean;
  55445. /**
  55446. * BJS is using an harcoded light falloff based on a manually sets up range.
  55447. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55448. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55449. */
  55450. set usePhysicalLightFalloff(value: boolean);
  55451. /**
  55452. * In order to support the falloff compatibility with gltf, a special mode has been added
  55453. * to reproduce the gltf light falloff.
  55454. */
  55455. get useGLTFLightFalloff(): boolean;
  55456. /**
  55457. * In order to support the falloff compatibility with gltf, a special mode has been added
  55458. * to reproduce the gltf light falloff.
  55459. */
  55460. set useGLTFLightFalloff(value: boolean);
  55461. /**
  55462. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55463. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55464. */
  55465. useRadianceOverAlpha: boolean;
  55466. /**
  55467. * Allows using an object space normal map (instead of tangent space).
  55468. */
  55469. useObjectSpaceNormalMap: boolean;
  55470. /**
  55471. * Allows using the bump map in parallax mode.
  55472. */
  55473. useParallax: boolean;
  55474. /**
  55475. * Allows using the bump map in parallax occlusion mode.
  55476. */
  55477. useParallaxOcclusion: boolean;
  55478. /**
  55479. * Controls the scale bias of the parallax mode.
  55480. */
  55481. parallaxScaleBias: number;
  55482. /**
  55483. * If sets to true, disables all the lights affecting the material.
  55484. */
  55485. disableLighting: boolean;
  55486. /**
  55487. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55488. */
  55489. forceIrradianceInFragment: boolean;
  55490. /**
  55491. * Number of Simultaneous lights allowed on the material.
  55492. */
  55493. maxSimultaneousLights: number;
  55494. /**
  55495. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55496. */
  55497. invertNormalMapX: boolean;
  55498. /**
  55499. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55500. */
  55501. invertNormalMapY: boolean;
  55502. /**
  55503. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55504. */
  55505. twoSidedLighting: boolean;
  55506. /**
  55507. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55508. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55509. */
  55510. useAlphaFresnel: boolean;
  55511. /**
  55512. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55513. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55514. */
  55515. useLinearAlphaFresnel: boolean;
  55516. /**
  55517. * Let user defines the brdf lookup texture used for IBL.
  55518. * A default 8bit version is embedded but you could point at :
  55519. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55520. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55521. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55522. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55523. */
  55524. environmentBRDFTexture: Nullable<BaseTexture>;
  55525. /**
  55526. * Force normal to face away from face.
  55527. */
  55528. forceNormalForward: boolean;
  55529. /**
  55530. * Enables specular anti aliasing in the PBR shader.
  55531. * It will both interacts on the Geometry for analytical and IBL lighting.
  55532. * It also prefilter the roughness map based on the bump values.
  55533. */
  55534. enableSpecularAntiAliasing: boolean;
  55535. /**
  55536. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55537. * makes the reflect vector face the model (under horizon).
  55538. */
  55539. useHorizonOcclusion: boolean;
  55540. /**
  55541. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55542. * too much the area relying on ambient texture to define their ambient occlusion.
  55543. */
  55544. useRadianceOcclusion: boolean;
  55545. /**
  55546. * If set to true, no lighting calculations will be applied.
  55547. */
  55548. unlit: boolean;
  55549. /**
  55550. * Gets the image processing configuration used either in this material.
  55551. */
  55552. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55553. /**
  55554. * Sets the Default image processing configuration used either in the this material.
  55555. *
  55556. * If sets to null, the scene one is in use.
  55557. */
  55558. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55559. /**
  55560. * Gets wether the color curves effect is enabled.
  55561. */
  55562. get cameraColorCurvesEnabled(): boolean;
  55563. /**
  55564. * Sets wether the color curves effect is enabled.
  55565. */
  55566. set cameraColorCurvesEnabled(value: boolean);
  55567. /**
  55568. * Gets wether the color grading effect is enabled.
  55569. */
  55570. get cameraColorGradingEnabled(): boolean;
  55571. /**
  55572. * Gets wether the color grading effect is enabled.
  55573. */
  55574. set cameraColorGradingEnabled(value: boolean);
  55575. /**
  55576. * Gets wether tonemapping is enabled or not.
  55577. */
  55578. get cameraToneMappingEnabled(): boolean;
  55579. /**
  55580. * Sets wether tonemapping is enabled or not
  55581. */
  55582. set cameraToneMappingEnabled(value: boolean);
  55583. /**
  55584. * The camera exposure used on this material.
  55585. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55586. * This corresponds to a photographic exposure.
  55587. */
  55588. get cameraExposure(): number;
  55589. /**
  55590. * The camera exposure used on this material.
  55591. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55592. * This corresponds to a photographic exposure.
  55593. */
  55594. set cameraExposure(value: number);
  55595. /**
  55596. * Gets The camera contrast used on this material.
  55597. */
  55598. get cameraContrast(): number;
  55599. /**
  55600. * Sets The camera contrast used on this material.
  55601. */
  55602. set cameraContrast(value: number);
  55603. /**
  55604. * Gets the Color Grading 2D Lookup Texture.
  55605. */
  55606. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55607. /**
  55608. * Sets the Color Grading 2D Lookup Texture.
  55609. */
  55610. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55611. /**
  55612. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55613. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55614. * 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;
  55615. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55616. */
  55617. get cameraColorCurves(): Nullable<ColorCurves>;
  55618. /**
  55619. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55620. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55621. * 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;
  55622. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55623. */
  55624. set cameraColorCurves(value: Nullable<ColorCurves>);
  55625. /**
  55626. * Instantiates a new PBRMaterial instance.
  55627. *
  55628. * @param name The material name
  55629. * @param scene The scene the material will be use in.
  55630. */
  55631. constructor(name: string, scene: Scene);
  55632. /**
  55633. * Returns the name of this material class.
  55634. */
  55635. getClassName(): string;
  55636. /**
  55637. * Makes a duplicate of the current material.
  55638. * @param name - name to use for the new material.
  55639. */
  55640. clone(name: string): PBRMaterial;
  55641. /**
  55642. * Serializes this PBR Material.
  55643. * @returns - An object with the serialized material.
  55644. */
  55645. serialize(): any;
  55646. /**
  55647. * Parses a PBR Material from a serialized object.
  55648. * @param source - Serialized object.
  55649. * @param scene - BJS scene instance.
  55650. * @param rootUrl - url for the scene object
  55651. * @returns - PBRMaterial
  55652. */
  55653. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  55654. }
  55655. }
  55656. declare module BABYLON {
  55657. /**
  55658. * Direct draw surface info
  55659. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  55660. */
  55661. export interface DDSInfo {
  55662. /**
  55663. * Width of the texture
  55664. */
  55665. width: number;
  55666. /**
  55667. * Width of the texture
  55668. */
  55669. height: number;
  55670. /**
  55671. * Number of Mipmaps for the texture
  55672. * @see https://en.wikipedia.org/wiki/Mipmap
  55673. */
  55674. mipmapCount: number;
  55675. /**
  55676. * If the textures format is a known fourCC format
  55677. * @see https://www.fourcc.org/
  55678. */
  55679. isFourCC: boolean;
  55680. /**
  55681. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  55682. */
  55683. isRGB: boolean;
  55684. /**
  55685. * If the texture is a lumincance format
  55686. */
  55687. isLuminance: boolean;
  55688. /**
  55689. * If this is a cube texture
  55690. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  55691. */
  55692. isCube: boolean;
  55693. /**
  55694. * If the texture is a compressed format eg. FOURCC_DXT1
  55695. */
  55696. isCompressed: boolean;
  55697. /**
  55698. * The dxgiFormat of the texture
  55699. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  55700. */
  55701. dxgiFormat: number;
  55702. /**
  55703. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  55704. */
  55705. textureType: number;
  55706. /**
  55707. * Sphericle polynomial created for the dds texture
  55708. */
  55709. sphericalPolynomial?: SphericalPolynomial;
  55710. }
  55711. /**
  55712. * Class used to provide DDS decompression tools
  55713. */
  55714. export class DDSTools {
  55715. /**
  55716. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  55717. */
  55718. static StoreLODInAlphaChannel: boolean;
  55719. /**
  55720. * Gets DDS information from an array buffer
  55721. * @param data defines the array buffer view to read data from
  55722. * @returns the DDS information
  55723. */
  55724. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  55725. private static _FloatView;
  55726. private static _Int32View;
  55727. private static _ToHalfFloat;
  55728. private static _FromHalfFloat;
  55729. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  55730. private static _GetHalfFloatRGBAArrayBuffer;
  55731. private static _GetFloatRGBAArrayBuffer;
  55732. private static _GetFloatAsUIntRGBAArrayBuffer;
  55733. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  55734. private static _GetRGBAArrayBuffer;
  55735. private static _ExtractLongWordOrder;
  55736. private static _GetRGBArrayBuffer;
  55737. private static _GetLuminanceArrayBuffer;
  55738. /**
  55739. * Uploads DDS Levels to a Babylon Texture
  55740. * @hidden
  55741. */
  55742. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  55743. }
  55744. interface ThinEngine {
  55745. /**
  55746. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  55747. * @param rootUrl defines the url where the file to load is located
  55748. * @param scene defines the current scene
  55749. * @param lodScale defines scale to apply to the mip map selection
  55750. * @param lodOffset defines offset to apply to the mip map selection
  55751. * @param onLoad defines an optional callback raised when the texture is loaded
  55752. * @param onError defines an optional callback raised if there is an issue to load the texture
  55753. * @param format defines the format of the data
  55754. * @param forcedExtension defines the extension to use to pick the right loader
  55755. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  55756. * @returns the cube texture as an InternalTexture
  55757. */
  55758. 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;
  55759. }
  55760. }
  55761. declare module BABYLON {
  55762. /**
  55763. * Implementation of the DDS Texture Loader.
  55764. * @hidden
  55765. */
  55766. export class _DDSTextureLoader implements IInternalTextureLoader {
  55767. /**
  55768. * Defines wether the loader supports cascade loading the different faces.
  55769. */
  55770. readonly supportCascades: boolean;
  55771. /**
  55772. * This returns if the loader support the current file information.
  55773. * @param extension defines the file extension of the file being loaded
  55774. * @returns true if the loader can load the specified file
  55775. */
  55776. canLoad(extension: string): boolean;
  55777. /**
  55778. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55779. * @param data contains the texture data
  55780. * @param texture defines the BabylonJS internal texture
  55781. * @param createPolynomials will be true if polynomials have been requested
  55782. * @param onLoad defines the callback to trigger once the texture is ready
  55783. * @param onError defines the callback to trigger in case of error
  55784. */
  55785. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55786. /**
  55787. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55788. * @param data contains the texture data
  55789. * @param texture defines the BabylonJS internal texture
  55790. * @param callback defines the method to call once ready to upload
  55791. */
  55792. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55793. }
  55794. }
  55795. declare module BABYLON {
  55796. /**
  55797. * Implementation of the ENV Texture Loader.
  55798. * @hidden
  55799. */
  55800. export class _ENVTextureLoader implements IInternalTextureLoader {
  55801. /**
  55802. * Defines wether the loader supports cascade loading the different faces.
  55803. */
  55804. readonly supportCascades: boolean;
  55805. /**
  55806. * This returns if the loader support the current file information.
  55807. * @param extension defines the file extension of the file being loaded
  55808. * @returns true if the loader can load the specified file
  55809. */
  55810. canLoad(extension: string): boolean;
  55811. /**
  55812. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55813. * @param data contains the texture data
  55814. * @param texture defines the BabylonJS internal texture
  55815. * @param createPolynomials will be true if polynomials have been requested
  55816. * @param onLoad defines the callback to trigger once the texture is ready
  55817. * @param onError defines the callback to trigger in case of error
  55818. */
  55819. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55820. /**
  55821. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55822. * @param data contains the texture data
  55823. * @param texture defines the BabylonJS internal texture
  55824. * @param callback defines the method to call once ready to upload
  55825. */
  55826. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55827. }
  55828. }
  55829. declare module BABYLON {
  55830. /**
  55831. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55832. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55833. */
  55834. export class KhronosTextureContainer {
  55835. /** contents of the KTX container file */
  55836. data: ArrayBufferView;
  55837. private static HEADER_LEN;
  55838. private static COMPRESSED_2D;
  55839. private static COMPRESSED_3D;
  55840. private static TEX_2D;
  55841. private static TEX_3D;
  55842. /**
  55843. * Gets the openGL type
  55844. */
  55845. glType: number;
  55846. /**
  55847. * Gets the openGL type size
  55848. */
  55849. glTypeSize: number;
  55850. /**
  55851. * Gets the openGL format
  55852. */
  55853. glFormat: number;
  55854. /**
  55855. * Gets the openGL internal format
  55856. */
  55857. glInternalFormat: number;
  55858. /**
  55859. * Gets the base internal format
  55860. */
  55861. glBaseInternalFormat: number;
  55862. /**
  55863. * Gets image width in pixel
  55864. */
  55865. pixelWidth: number;
  55866. /**
  55867. * Gets image height in pixel
  55868. */
  55869. pixelHeight: number;
  55870. /**
  55871. * Gets image depth in pixels
  55872. */
  55873. pixelDepth: number;
  55874. /**
  55875. * Gets the number of array elements
  55876. */
  55877. numberOfArrayElements: number;
  55878. /**
  55879. * Gets the number of faces
  55880. */
  55881. numberOfFaces: number;
  55882. /**
  55883. * Gets the number of mipmap levels
  55884. */
  55885. numberOfMipmapLevels: number;
  55886. /**
  55887. * Gets the bytes of key value data
  55888. */
  55889. bytesOfKeyValueData: number;
  55890. /**
  55891. * Gets the load type
  55892. */
  55893. loadType: number;
  55894. /**
  55895. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  55896. */
  55897. isInvalid: boolean;
  55898. /**
  55899. * Creates a new KhronosTextureContainer
  55900. * @param data contents of the KTX container file
  55901. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  55902. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  55903. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  55904. */
  55905. constructor(
  55906. /** contents of the KTX container file */
  55907. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55908. /**
  55909. * Uploads KTX content to a Babylon Texture.
  55910. * It is assumed that the texture has already been created & is currently bound
  55911. * @hidden
  55912. */
  55913. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55914. private _upload2DCompressedLevels;
  55915. /**
  55916. * Checks if the given data starts with a KTX file identifier.
  55917. * @param data the data to check
  55918. * @returns true if the data is a KTX file or false otherwise
  55919. */
  55920. static IsValid(data: ArrayBufferView): boolean;
  55921. }
  55922. }
  55923. declare module BABYLON {
  55924. /**
  55925. * Class for loading KTX2 files
  55926. * !!! Experimental Extension Subject to Changes !!!
  55927. * @hidden
  55928. */
  55929. export class KhronosTextureContainer2 {
  55930. private static _ModulePromise;
  55931. private static _TranscodeFormat;
  55932. constructor(engine: ThinEngine);
  55933. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55934. private _determineTranscodeFormat;
  55935. /**
  55936. * Checks if the given data starts with a KTX2 file identifier.
  55937. * @param data the data to check
  55938. * @returns true if the data is a KTX2 file or false otherwise
  55939. */
  55940. static IsValid(data: ArrayBufferView): boolean;
  55941. }
  55942. }
  55943. declare module BABYLON {
  55944. /**
  55945. * Implementation of the KTX Texture Loader.
  55946. * @hidden
  55947. */
  55948. export class _KTXTextureLoader implements IInternalTextureLoader {
  55949. /**
  55950. * Defines wether the loader supports cascade loading the different faces.
  55951. */
  55952. readonly supportCascades: boolean;
  55953. /**
  55954. * This returns if the loader support the current file information.
  55955. * @param extension defines the file extension of the file being loaded
  55956. * @returns true if the loader can load the specified file
  55957. */
  55958. canLoad(extension: string): boolean;
  55959. /**
  55960. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55961. * @param data contains the texture data
  55962. * @param texture defines the BabylonJS internal texture
  55963. * @param createPolynomials will be true if polynomials have been requested
  55964. * @param onLoad defines the callback to trigger once the texture is ready
  55965. * @param onError defines the callback to trigger in case of error
  55966. */
  55967. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55968. /**
  55969. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55970. * @param data contains the texture data
  55971. * @param texture defines the BabylonJS internal texture
  55972. * @param callback defines the method to call once ready to upload
  55973. */
  55974. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55975. }
  55976. }
  55977. declare module BABYLON {
  55978. /** @hidden */
  55979. export var _forceSceneHelpersToBundle: boolean;
  55980. interface Scene {
  55981. /**
  55982. * Creates a default light for the scene.
  55983. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55984. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55985. */
  55986. createDefaultLight(replace?: boolean): void;
  55987. /**
  55988. * Creates a default camera for the scene.
  55989. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55990. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55991. * @param replace has default false, when true replaces the active camera in the scene
  55992. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55993. */
  55994. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55995. /**
  55996. * Creates a default camera and a default light.
  55997. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55998. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55999. * @param replace has the default false, when true replaces the active camera/light in the scene
  56000. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56001. */
  56002. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56003. /**
  56004. * Creates a new sky box
  56005. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56006. * @param environmentTexture defines the texture to use as environment texture
  56007. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56008. * @param scale defines the overall scale of the skybox
  56009. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56010. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56011. * @returns a new mesh holding the sky box
  56012. */
  56013. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56014. /**
  56015. * Creates a new environment
  56016. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56017. * @param options defines the options you can use to configure the environment
  56018. * @returns the new EnvironmentHelper
  56019. */
  56020. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56021. /**
  56022. * Creates a new VREXperienceHelper
  56023. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56024. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56025. * @returns a new VREXperienceHelper
  56026. */
  56027. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56028. /**
  56029. * Creates a new WebXRDefaultExperience
  56030. * @see http://doc.babylonjs.com/how_to/webxr
  56031. * @param options experience options
  56032. * @returns a promise for a new WebXRDefaultExperience
  56033. */
  56034. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56035. }
  56036. }
  56037. declare module BABYLON {
  56038. /**
  56039. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56040. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56041. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56042. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56043. */
  56044. export class VideoDome extends TransformNode {
  56045. /**
  56046. * Define the video source as a Monoscopic panoramic 360 video.
  56047. */
  56048. static readonly MODE_MONOSCOPIC: number;
  56049. /**
  56050. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56051. */
  56052. static readonly MODE_TOPBOTTOM: number;
  56053. /**
  56054. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56055. */
  56056. static readonly MODE_SIDEBYSIDE: number;
  56057. private _halfDome;
  56058. private _useDirectMapping;
  56059. /**
  56060. * The video texture being displayed on the sphere
  56061. */
  56062. protected _videoTexture: VideoTexture;
  56063. /**
  56064. * Gets the video texture being displayed on the sphere
  56065. */
  56066. get videoTexture(): VideoTexture;
  56067. /**
  56068. * The skybox material
  56069. */
  56070. protected _material: BackgroundMaterial;
  56071. /**
  56072. * The surface used for the skybox
  56073. */
  56074. protected _mesh: Mesh;
  56075. /**
  56076. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56077. */
  56078. private _halfDomeMask;
  56079. /**
  56080. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56081. * Also see the options.resolution property.
  56082. */
  56083. get fovMultiplier(): number;
  56084. set fovMultiplier(value: number);
  56085. private _videoMode;
  56086. /**
  56087. * Gets or set the current video mode for the video. It can be:
  56088. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56089. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56090. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56091. */
  56092. get videoMode(): number;
  56093. set videoMode(value: number);
  56094. /**
  56095. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56096. *
  56097. */
  56098. get halfDome(): boolean;
  56099. /**
  56100. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56101. */
  56102. set halfDome(enabled: boolean);
  56103. /**
  56104. * Oberserver used in Stereoscopic VR Mode.
  56105. */
  56106. private _onBeforeCameraRenderObserver;
  56107. /**
  56108. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56109. * @param name Element's name, child elements will append suffixes for their own names.
  56110. * @param urlsOrVideo defines the url(s) or the video element to use
  56111. * @param options An object containing optional or exposed sub element properties
  56112. */
  56113. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56114. resolution?: number;
  56115. clickToPlay?: boolean;
  56116. autoPlay?: boolean;
  56117. loop?: boolean;
  56118. size?: number;
  56119. poster?: string;
  56120. faceForward?: boolean;
  56121. useDirectMapping?: boolean;
  56122. halfDomeMode?: boolean;
  56123. }, scene: Scene);
  56124. private _changeVideoMode;
  56125. /**
  56126. * Releases resources associated with this node.
  56127. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56128. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56129. */
  56130. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56131. }
  56132. }
  56133. declare module BABYLON {
  56134. /**
  56135. * This class can be used to get instrumentation data from a Babylon engine
  56136. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56137. */
  56138. export class EngineInstrumentation implements IDisposable {
  56139. /**
  56140. * Define the instrumented engine.
  56141. */
  56142. engine: Engine;
  56143. private _captureGPUFrameTime;
  56144. private _gpuFrameTimeToken;
  56145. private _gpuFrameTime;
  56146. private _captureShaderCompilationTime;
  56147. private _shaderCompilationTime;
  56148. private _onBeginFrameObserver;
  56149. private _onEndFrameObserver;
  56150. private _onBeforeShaderCompilationObserver;
  56151. private _onAfterShaderCompilationObserver;
  56152. /**
  56153. * Gets the perf counter used for GPU frame time
  56154. */
  56155. get gpuFrameTimeCounter(): PerfCounter;
  56156. /**
  56157. * Gets the GPU frame time capture status
  56158. */
  56159. get captureGPUFrameTime(): boolean;
  56160. /**
  56161. * Enable or disable the GPU frame time capture
  56162. */
  56163. set captureGPUFrameTime(value: boolean);
  56164. /**
  56165. * Gets the perf counter used for shader compilation time
  56166. */
  56167. get shaderCompilationTimeCounter(): PerfCounter;
  56168. /**
  56169. * Gets the shader compilation time capture status
  56170. */
  56171. get captureShaderCompilationTime(): boolean;
  56172. /**
  56173. * Enable or disable the shader compilation time capture
  56174. */
  56175. set captureShaderCompilationTime(value: boolean);
  56176. /**
  56177. * Instantiates a new engine instrumentation.
  56178. * This class can be used to get instrumentation data from a Babylon engine
  56179. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56180. * @param engine Defines the engine to instrument
  56181. */
  56182. constructor(
  56183. /**
  56184. * Define the instrumented engine.
  56185. */
  56186. engine: Engine);
  56187. /**
  56188. * Dispose and release associated resources.
  56189. */
  56190. dispose(): void;
  56191. }
  56192. }
  56193. declare module BABYLON {
  56194. /**
  56195. * This class can be used to get instrumentation data from a Babylon engine
  56196. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56197. */
  56198. export class SceneInstrumentation implements IDisposable {
  56199. /**
  56200. * Defines the scene to instrument
  56201. */
  56202. scene: Scene;
  56203. private _captureActiveMeshesEvaluationTime;
  56204. private _activeMeshesEvaluationTime;
  56205. private _captureRenderTargetsRenderTime;
  56206. private _renderTargetsRenderTime;
  56207. private _captureFrameTime;
  56208. private _frameTime;
  56209. private _captureRenderTime;
  56210. private _renderTime;
  56211. private _captureInterFrameTime;
  56212. private _interFrameTime;
  56213. private _captureParticlesRenderTime;
  56214. private _particlesRenderTime;
  56215. private _captureSpritesRenderTime;
  56216. private _spritesRenderTime;
  56217. private _capturePhysicsTime;
  56218. private _physicsTime;
  56219. private _captureAnimationsTime;
  56220. private _animationsTime;
  56221. private _captureCameraRenderTime;
  56222. private _cameraRenderTime;
  56223. private _onBeforeActiveMeshesEvaluationObserver;
  56224. private _onAfterActiveMeshesEvaluationObserver;
  56225. private _onBeforeRenderTargetsRenderObserver;
  56226. private _onAfterRenderTargetsRenderObserver;
  56227. private _onAfterRenderObserver;
  56228. private _onBeforeDrawPhaseObserver;
  56229. private _onAfterDrawPhaseObserver;
  56230. private _onBeforeAnimationsObserver;
  56231. private _onBeforeParticlesRenderingObserver;
  56232. private _onAfterParticlesRenderingObserver;
  56233. private _onBeforeSpritesRenderingObserver;
  56234. private _onAfterSpritesRenderingObserver;
  56235. private _onBeforePhysicsObserver;
  56236. private _onAfterPhysicsObserver;
  56237. private _onAfterAnimationsObserver;
  56238. private _onBeforeCameraRenderObserver;
  56239. private _onAfterCameraRenderObserver;
  56240. /**
  56241. * Gets the perf counter used for active meshes evaluation time
  56242. */
  56243. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56244. /**
  56245. * Gets the active meshes evaluation time capture status
  56246. */
  56247. get captureActiveMeshesEvaluationTime(): boolean;
  56248. /**
  56249. * Enable or disable the active meshes evaluation time capture
  56250. */
  56251. set captureActiveMeshesEvaluationTime(value: boolean);
  56252. /**
  56253. * Gets the perf counter used for render targets render time
  56254. */
  56255. get renderTargetsRenderTimeCounter(): PerfCounter;
  56256. /**
  56257. * Gets the render targets render time capture status
  56258. */
  56259. get captureRenderTargetsRenderTime(): boolean;
  56260. /**
  56261. * Enable or disable the render targets render time capture
  56262. */
  56263. set captureRenderTargetsRenderTime(value: boolean);
  56264. /**
  56265. * Gets the perf counter used for particles render time
  56266. */
  56267. get particlesRenderTimeCounter(): PerfCounter;
  56268. /**
  56269. * Gets the particles render time capture status
  56270. */
  56271. get captureParticlesRenderTime(): boolean;
  56272. /**
  56273. * Enable or disable the particles render time capture
  56274. */
  56275. set captureParticlesRenderTime(value: boolean);
  56276. /**
  56277. * Gets the perf counter used for sprites render time
  56278. */
  56279. get spritesRenderTimeCounter(): PerfCounter;
  56280. /**
  56281. * Gets the sprites render time capture status
  56282. */
  56283. get captureSpritesRenderTime(): boolean;
  56284. /**
  56285. * Enable or disable the sprites render time capture
  56286. */
  56287. set captureSpritesRenderTime(value: boolean);
  56288. /**
  56289. * Gets the perf counter used for physics time
  56290. */
  56291. get physicsTimeCounter(): PerfCounter;
  56292. /**
  56293. * Gets the physics time capture status
  56294. */
  56295. get capturePhysicsTime(): boolean;
  56296. /**
  56297. * Enable or disable the physics time capture
  56298. */
  56299. set capturePhysicsTime(value: boolean);
  56300. /**
  56301. * Gets the perf counter used for animations time
  56302. */
  56303. get animationsTimeCounter(): PerfCounter;
  56304. /**
  56305. * Gets the animations time capture status
  56306. */
  56307. get captureAnimationsTime(): boolean;
  56308. /**
  56309. * Enable or disable the animations time capture
  56310. */
  56311. set captureAnimationsTime(value: boolean);
  56312. /**
  56313. * Gets the perf counter used for frame time capture
  56314. */
  56315. get frameTimeCounter(): PerfCounter;
  56316. /**
  56317. * Gets the frame time capture status
  56318. */
  56319. get captureFrameTime(): boolean;
  56320. /**
  56321. * Enable or disable the frame time capture
  56322. */
  56323. set captureFrameTime(value: boolean);
  56324. /**
  56325. * Gets the perf counter used for inter-frames time capture
  56326. */
  56327. get interFrameTimeCounter(): PerfCounter;
  56328. /**
  56329. * Gets the inter-frames time capture status
  56330. */
  56331. get captureInterFrameTime(): boolean;
  56332. /**
  56333. * Enable or disable the inter-frames time capture
  56334. */
  56335. set captureInterFrameTime(value: boolean);
  56336. /**
  56337. * Gets the perf counter used for render time capture
  56338. */
  56339. get renderTimeCounter(): PerfCounter;
  56340. /**
  56341. * Gets the render time capture status
  56342. */
  56343. get captureRenderTime(): boolean;
  56344. /**
  56345. * Enable or disable the render time capture
  56346. */
  56347. set captureRenderTime(value: boolean);
  56348. /**
  56349. * Gets the perf counter used for camera render time capture
  56350. */
  56351. get cameraRenderTimeCounter(): PerfCounter;
  56352. /**
  56353. * Gets the camera render time capture status
  56354. */
  56355. get captureCameraRenderTime(): boolean;
  56356. /**
  56357. * Enable or disable the camera render time capture
  56358. */
  56359. set captureCameraRenderTime(value: boolean);
  56360. /**
  56361. * Gets the perf counter used for draw calls
  56362. */
  56363. get drawCallsCounter(): PerfCounter;
  56364. /**
  56365. * Instantiates a new scene instrumentation.
  56366. * This class can be used to get instrumentation data from a Babylon engine
  56367. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56368. * @param scene Defines the scene to instrument
  56369. */
  56370. constructor(
  56371. /**
  56372. * Defines the scene to instrument
  56373. */
  56374. scene: Scene);
  56375. /**
  56376. * Dispose and release associated resources.
  56377. */
  56378. dispose(): void;
  56379. }
  56380. }
  56381. declare module BABYLON {
  56382. /** @hidden */
  56383. export var glowMapGenerationPixelShader: {
  56384. name: string;
  56385. shader: string;
  56386. };
  56387. }
  56388. declare module BABYLON {
  56389. /** @hidden */
  56390. export var glowMapGenerationVertexShader: {
  56391. name: string;
  56392. shader: string;
  56393. };
  56394. }
  56395. declare module BABYLON {
  56396. /**
  56397. * Effect layer options. This helps customizing the behaviour
  56398. * of the effect layer.
  56399. */
  56400. export interface IEffectLayerOptions {
  56401. /**
  56402. * Multiplication factor apply to the canvas size to compute the render target size
  56403. * used to generated the objects (the smaller the faster).
  56404. */
  56405. mainTextureRatio: number;
  56406. /**
  56407. * Enforces a fixed size texture to ensure effect stability across devices.
  56408. */
  56409. mainTextureFixedSize?: number;
  56410. /**
  56411. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56412. */
  56413. alphaBlendingMode: number;
  56414. /**
  56415. * The camera attached to the layer.
  56416. */
  56417. camera: Nullable<Camera>;
  56418. /**
  56419. * The rendering group to draw the layer in.
  56420. */
  56421. renderingGroupId: number;
  56422. }
  56423. /**
  56424. * The effect layer Helps adding post process effect blended with the main pass.
  56425. *
  56426. * This can be for instance use to generate glow or higlight effects on the scene.
  56427. *
  56428. * The effect layer class can not be used directly and is intented to inherited from to be
  56429. * customized per effects.
  56430. */
  56431. export abstract class EffectLayer {
  56432. private _vertexBuffers;
  56433. private _indexBuffer;
  56434. private _cachedDefines;
  56435. private _effectLayerMapGenerationEffect;
  56436. private _effectLayerOptions;
  56437. private _mergeEffect;
  56438. protected _scene: Scene;
  56439. protected _engine: Engine;
  56440. protected _maxSize: number;
  56441. protected _mainTextureDesiredSize: ISize;
  56442. protected _mainTexture: RenderTargetTexture;
  56443. protected _shouldRender: boolean;
  56444. protected _postProcesses: PostProcess[];
  56445. protected _textures: BaseTexture[];
  56446. protected _emissiveTextureAndColor: {
  56447. texture: Nullable<BaseTexture>;
  56448. color: Color4;
  56449. };
  56450. /**
  56451. * The name of the layer
  56452. */
  56453. name: string;
  56454. /**
  56455. * The clear color of the texture used to generate the glow map.
  56456. */
  56457. neutralColor: Color4;
  56458. /**
  56459. * Specifies whether the highlight layer is enabled or not.
  56460. */
  56461. isEnabled: boolean;
  56462. /**
  56463. * Gets the camera attached to the layer.
  56464. */
  56465. get camera(): Nullable<Camera>;
  56466. /**
  56467. * Gets the rendering group id the layer should render in.
  56468. */
  56469. get renderingGroupId(): number;
  56470. set renderingGroupId(renderingGroupId: number);
  56471. /**
  56472. * An event triggered when the effect layer has been disposed.
  56473. */
  56474. onDisposeObservable: Observable<EffectLayer>;
  56475. /**
  56476. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56477. */
  56478. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56479. /**
  56480. * An event triggered when the generated texture is being merged in the scene.
  56481. */
  56482. onBeforeComposeObservable: Observable<EffectLayer>;
  56483. /**
  56484. * An event triggered when the mesh is rendered into the effect render target.
  56485. */
  56486. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56487. /**
  56488. * An event triggered after the mesh has been rendered into the effect render target.
  56489. */
  56490. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56491. /**
  56492. * An event triggered when the generated texture has been merged in the scene.
  56493. */
  56494. onAfterComposeObservable: Observable<EffectLayer>;
  56495. /**
  56496. * An event triggered when the efffect layer changes its size.
  56497. */
  56498. onSizeChangedObservable: Observable<EffectLayer>;
  56499. /** @hidden */
  56500. static _SceneComponentInitialization: (scene: Scene) => void;
  56501. /**
  56502. * Instantiates a new effect Layer and references it in the scene.
  56503. * @param name The name of the layer
  56504. * @param scene The scene to use the layer in
  56505. */
  56506. constructor(
  56507. /** The Friendly of the effect in the scene */
  56508. name: string, scene: Scene);
  56509. /**
  56510. * Get the effect name of the layer.
  56511. * @return The effect name
  56512. */
  56513. abstract getEffectName(): string;
  56514. /**
  56515. * Checks for the readiness of the element composing the layer.
  56516. * @param subMesh the mesh to check for
  56517. * @param useInstances specify whether or not to use instances to render the mesh
  56518. * @return true if ready otherwise, false
  56519. */
  56520. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56521. /**
  56522. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56523. * @returns true if the effect requires stencil during the main canvas render pass.
  56524. */
  56525. abstract needStencil(): boolean;
  56526. /**
  56527. * Create the merge effect. This is the shader use to blit the information back
  56528. * to the main canvas at the end of the scene rendering.
  56529. * @returns The effect containing the shader used to merge the effect on the main canvas
  56530. */
  56531. protected abstract _createMergeEffect(): Effect;
  56532. /**
  56533. * Creates the render target textures and post processes used in the effect layer.
  56534. */
  56535. protected abstract _createTextureAndPostProcesses(): void;
  56536. /**
  56537. * Implementation specific of rendering the generating effect on the main canvas.
  56538. * @param effect The effect used to render through
  56539. */
  56540. protected abstract _internalRender(effect: Effect): void;
  56541. /**
  56542. * Sets the required values for both the emissive texture and and the main color.
  56543. */
  56544. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56545. /**
  56546. * Free any resources and references associated to a mesh.
  56547. * Internal use
  56548. * @param mesh The mesh to free.
  56549. */
  56550. abstract _disposeMesh(mesh: Mesh): void;
  56551. /**
  56552. * Serializes this layer (Glow or Highlight for example)
  56553. * @returns a serialized layer object
  56554. */
  56555. abstract serialize?(): any;
  56556. /**
  56557. * Initializes the effect layer with the required options.
  56558. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56559. */
  56560. protected _init(options: Partial<IEffectLayerOptions>): void;
  56561. /**
  56562. * Generates the index buffer of the full screen quad blending to the main canvas.
  56563. */
  56564. private _generateIndexBuffer;
  56565. /**
  56566. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56567. */
  56568. private _generateVertexBuffer;
  56569. /**
  56570. * Sets the main texture desired size which is the closest power of two
  56571. * of the engine canvas size.
  56572. */
  56573. private _setMainTextureSize;
  56574. /**
  56575. * Creates the main texture for the effect layer.
  56576. */
  56577. protected _createMainTexture(): void;
  56578. /**
  56579. * Adds specific effects defines.
  56580. * @param defines The defines to add specifics to.
  56581. */
  56582. protected _addCustomEffectDefines(defines: string[]): void;
  56583. /**
  56584. * Checks for the readiness of the element composing the layer.
  56585. * @param subMesh the mesh to check for
  56586. * @param useInstances specify whether or not to use instances to render the mesh
  56587. * @param emissiveTexture the associated emissive texture used to generate the glow
  56588. * @return true if ready otherwise, false
  56589. */
  56590. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  56591. /**
  56592. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  56593. */
  56594. render(): void;
  56595. /**
  56596. * Determine if a given mesh will be used in the current effect.
  56597. * @param mesh mesh to test
  56598. * @returns true if the mesh will be used
  56599. */
  56600. hasMesh(mesh: AbstractMesh): boolean;
  56601. /**
  56602. * Returns true if the layer contains information to display, otherwise false.
  56603. * @returns true if the glow layer should be rendered
  56604. */
  56605. shouldRender(): boolean;
  56606. /**
  56607. * Returns true if the mesh should render, otherwise false.
  56608. * @param mesh The mesh to render
  56609. * @returns true if it should render otherwise false
  56610. */
  56611. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  56612. /**
  56613. * Returns true if the mesh can be rendered, otherwise false.
  56614. * @param mesh The mesh to render
  56615. * @param material The material used on the mesh
  56616. * @returns true if it can be rendered otherwise false
  56617. */
  56618. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56619. /**
  56620. * Returns true if the mesh should render, otherwise false.
  56621. * @param mesh The mesh to render
  56622. * @returns true if it should render otherwise false
  56623. */
  56624. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  56625. /**
  56626. * Renders the submesh passed in parameter to the generation map.
  56627. */
  56628. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  56629. /**
  56630. * Defines whether the current material of the mesh should be use to render the effect.
  56631. * @param mesh defines the current mesh to render
  56632. */
  56633. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56634. /**
  56635. * Rebuild the required buffers.
  56636. * @hidden Internal use only.
  56637. */
  56638. _rebuild(): void;
  56639. /**
  56640. * Dispose only the render target textures and post process.
  56641. */
  56642. private _disposeTextureAndPostProcesses;
  56643. /**
  56644. * Dispose the highlight layer and free resources.
  56645. */
  56646. dispose(): void;
  56647. /**
  56648. * Gets the class name of the effect layer
  56649. * @returns the string with the class name of the effect layer
  56650. */
  56651. getClassName(): string;
  56652. /**
  56653. * Creates an effect layer from parsed effect layer data
  56654. * @param parsedEffectLayer defines effect layer data
  56655. * @param scene defines the current scene
  56656. * @param rootUrl defines the root URL containing the effect layer information
  56657. * @returns a parsed effect Layer
  56658. */
  56659. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  56660. }
  56661. }
  56662. declare module BABYLON {
  56663. interface AbstractScene {
  56664. /**
  56665. * The list of effect layers (highlights/glow) added to the scene
  56666. * @see http://doc.babylonjs.com/how_to/highlight_layer
  56667. * @see http://doc.babylonjs.com/how_to/glow_layer
  56668. */
  56669. effectLayers: Array<EffectLayer>;
  56670. /**
  56671. * Removes the given effect layer from this scene.
  56672. * @param toRemove defines the effect layer to remove
  56673. * @returns the index of the removed effect layer
  56674. */
  56675. removeEffectLayer(toRemove: EffectLayer): number;
  56676. /**
  56677. * Adds the given effect layer to this scene
  56678. * @param newEffectLayer defines the effect layer to add
  56679. */
  56680. addEffectLayer(newEffectLayer: EffectLayer): void;
  56681. }
  56682. /**
  56683. * Defines the layer scene component responsible to manage any effect layers
  56684. * in a given scene.
  56685. */
  56686. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  56687. /**
  56688. * The component name helpfull to identify the component in the list of scene components.
  56689. */
  56690. readonly name: string;
  56691. /**
  56692. * The scene the component belongs to.
  56693. */
  56694. scene: Scene;
  56695. private _engine;
  56696. private _renderEffects;
  56697. private _needStencil;
  56698. private _previousStencilState;
  56699. /**
  56700. * Creates a new instance of the component for the given scene
  56701. * @param scene Defines the scene to register the component in
  56702. */
  56703. constructor(scene: Scene);
  56704. /**
  56705. * Registers the component in a given scene
  56706. */
  56707. register(): void;
  56708. /**
  56709. * Rebuilds the elements related to this component in case of
  56710. * context lost for instance.
  56711. */
  56712. rebuild(): void;
  56713. /**
  56714. * Serializes the component data to the specified json object
  56715. * @param serializationObject The object to serialize to
  56716. */
  56717. serialize(serializationObject: any): void;
  56718. /**
  56719. * Adds all the elements from the container to the scene
  56720. * @param container the container holding the elements
  56721. */
  56722. addFromContainer(container: AbstractScene): void;
  56723. /**
  56724. * Removes all the elements in the container from the scene
  56725. * @param container contains the elements to remove
  56726. * @param dispose if the removed element should be disposed (default: false)
  56727. */
  56728. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56729. /**
  56730. * Disposes the component and the associated ressources.
  56731. */
  56732. dispose(): void;
  56733. private _isReadyForMesh;
  56734. private _renderMainTexture;
  56735. private _setStencil;
  56736. private _setStencilBack;
  56737. private _draw;
  56738. private _drawCamera;
  56739. private _drawRenderingGroup;
  56740. }
  56741. }
  56742. declare module BABYLON {
  56743. /** @hidden */
  56744. export var glowMapMergePixelShader: {
  56745. name: string;
  56746. shader: string;
  56747. };
  56748. }
  56749. declare module BABYLON {
  56750. /** @hidden */
  56751. export var glowMapMergeVertexShader: {
  56752. name: string;
  56753. shader: string;
  56754. };
  56755. }
  56756. declare module BABYLON {
  56757. interface AbstractScene {
  56758. /**
  56759. * Return a the first highlight layer of the scene with a given name.
  56760. * @param name The name of the highlight layer to look for.
  56761. * @return The highlight layer if found otherwise null.
  56762. */
  56763. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  56764. }
  56765. /**
  56766. * Glow layer options. This helps customizing the behaviour
  56767. * of the glow layer.
  56768. */
  56769. export interface IGlowLayerOptions {
  56770. /**
  56771. * Multiplication factor apply to the canvas size to compute the render target size
  56772. * used to generated the glowing objects (the smaller the faster).
  56773. */
  56774. mainTextureRatio: number;
  56775. /**
  56776. * Enforces a fixed size texture to ensure resize independant blur.
  56777. */
  56778. mainTextureFixedSize?: number;
  56779. /**
  56780. * How big is the kernel of the blur texture.
  56781. */
  56782. blurKernelSize: number;
  56783. /**
  56784. * The camera attached to the layer.
  56785. */
  56786. camera: Nullable<Camera>;
  56787. /**
  56788. * Enable MSAA by chosing the number of samples.
  56789. */
  56790. mainTextureSamples?: number;
  56791. /**
  56792. * The rendering group to draw the layer in.
  56793. */
  56794. renderingGroupId: number;
  56795. }
  56796. /**
  56797. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  56798. *
  56799. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  56800. *
  56801. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  56802. */
  56803. export class GlowLayer extends EffectLayer {
  56804. /**
  56805. * Effect Name of the layer.
  56806. */
  56807. static readonly EffectName: string;
  56808. /**
  56809. * The default blur kernel size used for the glow.
  56810. */
  56811. static DefaultBlurKernelSize: number;
  56812. /**
  56813. * The default texture size ratio used for the glow.
  56814. */
  56815. static DefaultTextureRatio: number;
  56816. /**
  56817. * Sets the kernel size of the blur.
  56818. */
  56819. set blurKernelSize(value: number);
  56820. /**
  56821. * Gets the kernel size of the blur.
  56822. */
  56823. get blurKernelSize(): number;
  56824. /**
  56825. * Sets the glow intensity.
  56826. */
  56827. set intensity(value: number);
  56828. /**
  56829. * Gets the glow intensity.
  56830. */
  56831. get intensity(): number;
  56832. private _options;
  56833. private _intensity;
  56834. private _horizontalBlurPostprocess1;
  56835. private _verticalBlurPostprocess1;
  56836. private _horizontalBlurPostprocess2;
  56837. private _verticalBlurPostprocess2;
  56838. private _blurTexture1;
  56839. private _blurTexture2;
  56840. private _postProcesses1;
  56841. private _postProcesses2;
  56842. private _includedOnlyMeshes;
  56843. private _excludedMeshes;
  56844. private _meshesUsingTheirOwnMaterials;
  56845. /**
  56846. * Callback used to let the user override the color selection on a per mesh basis
  56847. */
  56848. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56849. /**
  56850. * Callback used to let the user override the texture selection on a per mesh basis
  56851. */
  56852. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56853. /**
  56854. * Instantiates a new glow Layer and references it to the scene.
  56855. * @param name The name of the layer
  56856. * @param scene The scene to use the layer in
  56857. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56858. */
  56859. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56860. /**
  56861. * Get the effect name of the layer.
  56862. * @return The effect name
  56863. */
  56864. getEffectName(): string;
  56865. /**
  56866. * Create the merge effect. This is the shader use to blit the information back
  56867. * to the main canvas at the end of the scene rendering.
  56868. */
  56869. protected _createMergeEffect(): Effect;
  56870. /**
  56871. * Creates the render target textures and post processes used in the glow layer.
  56872. */
  56873. protected _createTextureAndPostProcesses(): void;
  56874. /**
  56875. * Checks for the readiness of the element composing the layer.
  56876. * @param subMesh the mesh to check for
  56877. * @param useInstances specify wether or not to use instances to render the mesh
  56878. * @param emissiveTexture the associated emissive texture used to generate the glow
  56879. * @return true if ready otherwise, false
  56880. */
  56881. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56882. /**
  56883. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56884. */
  56885. needStencil(): boolean;
  56886. /**
  56887. * Returns true if the mesh can be rendered, otherwise false.
  56888. * @param mesh The mesh to render
  56889. * @param material The material used on the mesh
  56890. * @returns true if it can be rendered otherwise false
  56891. */
  56892. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56893. /**
  56894. * Implementation specific of rendering the generating effect on the main canvas.
  56895. * @param effect The effect used to render through
  56896. */
  56897. protected _internalRender(effect: Effect): void;
  56898. /**
  56899. * Sets the required values for both the emissive texture and and the main color.
  56900. */
  56901. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56902. /**
  56903. * Returns true if the mesh should render, otherwise false.
  56904. * @param mesh The mesh to render
  56905. * @returns true if it should render otherwise false
  56906. */
  56907. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56908. /**
  56909. * Adds specific effects defines.
  56910. * @param defines The defines to add specifics to.
  56911. */
  56912. protected _addCustomEffectDefines(defines: string[]): void;
  56913. /**
  56914. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56915. * @param mesh The mesh to exclude from the glow layer
  56916. */
  56917. addExcludedMesh(mesh: Mesh): void;
  56918. /**
  56919. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56920. * @param mesh The mesh to remove
  56921. */
  56922. removeExcludedMesh(mesh: Mesh): void;
  56923. /**
  56924. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56925. * @param mesh The mesh to include in the glow layer
  56926. */
  56927. addIncludedOnlyMesh(mesh: Mesh): void;
  56928. /**
  56929. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56930. * @param mesh The mesh to remove
  56931. */
  56932. removeIncludedOnlyMesh(mesh: Mesh): void;
  56933. /**
  56934. * Determine if a given mesh will be used in the glow layer
  56935. * @param mesh The mesh to test
  56936. * @returns true if the mesh will be highlighted by the current glow layer
  56937. */
  56938. hasMesh(mesh: AbstractMesh): boolean;
  56939. /**
  56940. * Defines whether the current material of the mesh should be use to render the effect.
  56941. * @param mesh defines the current mesh to render
  56942. */
  56943. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56944. /**
  56945. * Add a mesh to be rendered through its own material and not with emissive only.
  56946. * @param mesh The mesh for which we need to use its material
  56947. */
  56948. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56949. /**
  56950. * Remove a mesh from being rendered through its own material and not with emissive only.
  56951. * @param mesh The mesh for which we need to not use its material
  56952. */
  56953. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56954. /**
  56955. * Free any resources and references associated to a mesh.
  56956. * Internal use
  56957. * @param mesh The mesh to free.
  56958. * @hidden
  56959. */
  56960. _disposeMesh(mesh: Mesh): void;
  56961. /**
  56962. * Gets the class name of the effect layer
  56963. * @returns the string with the class name of the effect layer
  56964. */
  56965. getClassName(): string;
  56966. /**
  56967. * Serializes this glow layer
  56968. * @returns a serialized glow layer object
  56969. */
  56970. serialize(): any;
  56971. /**
  56972. * Creates a Glow Layer from parsed glow layer data
  56973. * @param parsedGlowLayer defines glow layer data
  56974. * @param scene defines the current scene
  56975. * @param rootUrl defines the root URL containing the glow layer information
  56976. * @returns a parsed Glow Layer
  56977. */
  56978. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56979. }
  56980. }
  56981. declare module BABYLON {
  56982. /** @hidden */
  56983. export var glowBlurPostProcessPixelShader: {
  56984. name: string;
  56985. shader: string;
  56986. };
  56987. }
  56988. declare module BABYLON {
  56989. interface AbstractScene {
  56990. /**
  56991. * Return a the first highlight layer of the scene with a given name.
  56992. * @param name The name of the highlight layer to look for.
  56993. * @return The highlight layer if found otherwise null.
  56994. */
  56995. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56996. }
  56997. /**
  56998. * Highlight layer options. This helps customizing the behaviour
  56999. * of the highlight layer.
  57000. */
  57001. export interface IHighlightLayerOptions {
  57002. /**
  57003. * Multiplication factor apply to the canvas size to compute the render target size
  57004. * used to generated the glowing objects (the smaller the faster).
  57005. */
  57006. mainTextureRatio: number;
  57007. /**
  57008. * Enforces a fixed size texture to ensure resize independant blur.
  57009. */
  57010. mainTextureFixedSize?: number;
  57011. /**
  57012. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57013. * of the picture to blur (the smaller the faster).
  57014. */
  57015. blurTextureSizeRatio: number;
  57016. /**
  57017. * How big in texel of the blur texture is the vertical blur.
  57018. */
  57019. blurVerticalSize: number;
  57020. /**
  57021. * How big in texel of the blur texture is the horizontal blur.
  57022. */
  57023. blurHorizontalSize: number;
  57024. /**
  57025. * Alpha blending mode used to apply the blur. Default is combine.
  57026. */
  57027. alphaBlendingMode: number;
  57028. /**
  57029. * The camera attached to the layer.
  57030. */
  57031. camera: Nullable<Camera>;
  57032. /**
  57033. * Should we display highlight as a solid stroke?
  57034. */
  57035. isStroke?: boolean;
  57036. /**
  57037. * The rendering group to draw the layer in.
  57038. */
  57039. renderingGroupId: number;
  57040. }
  57041. /**
  57042. * The highlight layer Helps adding a glow effect around a mesh.
  57043. *
  57044. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57045. * glowy meshes to your scene.
  57046. *
  57047. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57048. */
  57049. export class HighlightLayer extends EffectLayer {
  57050. name: string;
  57051. /**
  57052. * Effect Name of the highlight layer.
  57053. */
  57054. static readonly EffectName: string;
  57055. /**
  57056. * The neutral color used during the preparation of the glow effect.
  57057. * This is black by default as the blend operation is a blend operation.
  57058. */
  57059. static NeutralColor: Color4;
  57060. /**
  57061. * Stencil value used for glowing meshes.
  57062. */
  57063. static GlowingMeshStencilReference: number;
  57064. /**
  57065. * Stencil value used for the other meshes in the scene.
  57066. */
  57067. static NormalMeshStencilReference: number;
  57068. /**
  57069. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57070. */
  57071. innerGlow: boolean;
  57072. /**
  57073. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57074. */
  57075. outerGlow: boolean;
  57076. /**
  57077. * Specifies the horizontal size of the blur.
  57078. */
  57079. set blurHorizontalSize(value: number);
  57080. /**
  57081. * Specifies the vertical size of the blur.
  57082. */
  57083. set blurVerticalSize(value: number);
  57084. /**
  57085. * Gets the horizontal size of the blur.
  57086. */
  57087. get blurHorizontalSize(): number;
  57088. /**
  57089. * Gets the vertical size of the blur.
  57090. */
  57091. get blurVerticalSize(): number;
  57092. /**
  57093. * An event triggered when the highlight layer is being blurred.
  57094. */
  57095. onBeforeBlurObservable: Observable<HighlightLayer>;
  57096. /**
  57097. * An event triggered when the highlight layer has been blurred.
  57098. */
  57099. onAfterBlurObservable: Observable<HighlightLayer>;
  57100. private _instanceGlowingMeshStencilReference;
  57101. private _options;
  57102. private _downSamplePostprocess;
  57103. private _horizontalBlurPostprocess;
  57104. private _verticalBlurPostprocess;
  57105. private _blurTexture;
  57106. private _meshes;
  57107. private _excludedMeshes;
  57108. /**
  57109. * Instantiates a new highlight Layer and references it to the scene..
  57110. * @param name The name of the layer
  57111. * @param scene The scene to use the layer in
  57112. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57113. */
  57114. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57115. /**
  57116. * Get the effect name of the layer.
  57117. * @return The effect name
  57118. */
  57119. getEffectName(): string;
  57120. /**
  57121. * Create the merge effect. This is the shader use to blit the information back
  57122. * to the main canvas at the end of the scene rendering.
  57123. */
  57124. protected _createMergeEffect(): Effect;
  57125. /**
  57126. * Creates the render target textures and post processes used in the highlight layer.
  57127. */
  57128. protected _createTextureAndPostProcesses(): void;
  57129. /**
  57130. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57131. */
  57132. needStencil(): boolean;
  57133. /**
  57134. * Checks for the readiness of the element composing the layer.
  57135. * @param subMesh the mesh to check for
  57136. * @param useInstances specify wether or not to use instances to render the mesh
  57137. * @param emissiveTexture the associated emissive texture used to generate the glow
  57138. * @return true if ready otherwise, false
  57139. */
  57140. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57141. /**
  57142. * Implementation specific of rendering the generating effect on the main canvas.
  57143. * @param effect The effect used to render through
  57144. */
  57145. protected _internalRender(effect: Effect): void;
  57146. /**
  57147. * Returns true if the layer contains information to display, otherwise false.
  57148. */
  57149. shouldRender(): boolean;
  57150. /**
  57151. * Returns true if the mesh should render, otherwise false.
  57152. * @param mesh The mesh to render
  57153. * @returns true if it should render otherwise false
  57154. */
  57155. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57156. /**
  57157. * Adds specific effects defines.
  57158. * @param defines The defines to add specifics to.
  57159. */
  57160. protected _addCustomEffectDefines(defines: string[]): void;
  57161. /**
  57162. * Sets the required values for both the emissive texture and and the main color.
  57163. */
  57164. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57165. /**
  57166. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57167. * @param mesh The mesh to exclude from the highlight layer
  57168. */
  57169. addExcludedMesh(mesh: Mesh): void;
  57170. /**
  57171. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57172. * @param mesh The mesh to highlight
  57173. */
  57174. removeExcludedMesh(mesh: Mesh): void;
  57175. /**
  57176. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57177. * @param mesh mesh to test
  57178. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57179. */
  57180. hasMesh(mesh: AbstractMesh): boolean;
  57181. /**
  57182. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57183. * @param mesh The mesh to highlight
  57184. * @param color The color of the highlight
  57185. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57186. */
  57187. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57188. /**
  57189. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57190. * @param mesh The mesh to highlight
  57191. */
  57192. removeMesh(mesh: Mesh): void;
  57193. /**
  57194. * Remove all the meshes currently referenced in the highlight layer
  57195. */
  57196. removeAllMeshes(): void;
  57197. /**
  57198. * Force the stencil to the normal expected value for none glowing parts
  57199. */
  57200. private _defaultStencilReference;
  57201. /**
  57202. * Free any resources and references associated to a mesh.
  57203. * Internal use
  57204. * @param mesh The mesh to free.
  57205. * @hidden
  57206. */
  57207. _disposeMesh(mesh: Mesh): void;
  57208. /**
  57209. * Dispose the highlight layer and free resources.
  57210. */
  57211. dispose(): void;
  57212. /**
  57213. * Gets the class name of the effect layer
  57214. * @returns the string with the class name of the effect layer
  57215. */
  57216. getClassName(): string;
  57217. /**
  57218. * Serializes this Highlight layer
  57219. * @returns a serialized Highlight layer object
  57220. */
  57221. serialize(): any;
  57222. /**
  57223. * Creates a Highlight layer from parsed Highlight layer data
  57224. * @param parsedHightlightLayer defines the Highlight layer data
  57225. * @param scene defines the current scene
  57226. * @param rootUrl defines the root URL containing the Highlight layer information
  57227. * @returns a parsed Highlight layer
  57228. */
  57229. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57230. }
  57231. }
  57232. declare module BABYLON {
  57233. interface AbstractScene {
  57234. /**
  57235. * The list of layers (background and foreground) of the scene
  57236. */
  57237. layers: Array<Layer>;
  57238. }
  57239. /**
  57240. * Defines the layer scene component responsible to manage any layers
  57241. * in a given scene.
  57242. */
  57243. export class LayerSceneComponent implements ISceneComponent {
  57244. /**
  57245. * The component name helpfull to identify the component in the list of scene components.
  57246. */
  57247. readonly name: string;
  57248. /**
  57249. * The scene the component belongs to.
  57250. */
  57251. scene: Scene;
  57252. private _engine;
  57253. /**
  57254. * Creates a new instance of the component for the given scene
  57255. * @param scene Defines the scene to register the component in
  57256. */
  57257. constructor(scene: Scene);
  57258. /**
  57259. * Registers the component in a given scene
  57260. */
  57261. register(): void;
  57262. /**
  57263. * Rebuilds the elements related to this component in case of
  57264. * context lost for instance.
  57265. */
  57266. rebuild(): void;
  57267. /**
  57268. * Disposes the component and the associated ressources.
  57269. */
  57270. dispose(): void;
  57271. private _draw;
  57272. private _drawCameraPredicate;
  57273. private _drawCameraBackground;
  57274. private _drawCameraForeground;
  57275. private _drawRenderTargetPredicate;
  57276. private _drawRenderTargetBackground;
  57277. private _drawRenderTargetForeground;
  57278. /**
  57279. * Adds all the elements from the container to the scene
  57280. * @param container the container holding the elements
  57281. */
  57282. addFromContainer(container: AbstractScene): void;
  57283. /**
  57284. * Removes all the elements in the container from the scene
  57285. * @param container contains the elements to remove
  57286. * @param dispose if the removed element should be disposed (default: false)
  57287. */
  57288. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57289. }
  57290. }
  57291. declare module BABYLON {
  57292. /** @hidden */
  57293. export var layerPixelShader: {
  57294. name: string;
  57295. shader: string;
  57296. };
  57297. }
  57298. declare module BABYLON {
  57299. /** @hidden */
  57300. export var layerVertexShader: {
  57301. name: string;
  57302. shader: string;
  57303. };
  57304. }
  57305. declare module BABYLON {
  57306. /**
  57307. * This represents a full screen 2d layer.
  57308. * This can be useful to display a picture in the background of your scene for instance.
  57309. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57310. */
  57311. export class Layer {
  57312. /**
  57313. * Define the name of the layer.
  57314. */
  57315. name: string;
  57316. /**
  57317. * Define the texture the layer should display.
  57318. */
  57319. texture: Nullable<Texture>;
  57320. /**
  57321. * Is the layer in background or foreground.
  57322. */
  57323. isBackground: boolean;
  57324. /**
  57325. * Define the color of the layer (instead of texture).
  57326. */
  57327. color: Color4;
  57328. /**
  57329. * Define the scale of the layer in order to zoom in out of the texture.
  57330. */
  57331. scale: Vector2;
  57332. /**
  57333. * Define an offset for the layer in order to shift the texture.
  57334. */
  57335. offset: Vector2;
  57336. /**
  57337. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57338. */
  57339. alphaBlendingMode: number;
  57340. /**
  57341. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57342. * Alpha test will not mix with the background color in case of transparency.
  57343. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57344. */
  57345. alphaTest: boolean;
  57346. /**
  57347. * Define a mask to restrict the layer to only some of the scene cameras.
  57348. */
  57349. layerMask: number;
  57350. /**
  57351. * Define the list of render target the layer is visible into.
  57352. */
  57353. renderTargetTextures: RenderTargetTexture[];
  57354. /**
  57355. * Define if the layer is only used in renderTarget or if it also
  57356. * renders in the main frame buffer of the canvas.
  57357. */
  57358. renderOnlyInRenderTargetTextures: boolean;
  57359. private _scene;
  57360. private _vertexBuffers;
  57361. private _indexBuffer;
  57362. private _effect;
  57363. private _previousDefines;
  57364. /**
  57365. * An event triggered when the layer is disposed.
  57366. */
  57367. onDisposeObservable: Observable<Layer>;
  57368. private _onDisposeObserver;
  57369. /**
  57370. * Back compatibility with callback before the onDisposeObservable existed.
  57371. * The set callback will be triggered when the layer has been disposed.
  57372. */
  57373. set onDispose(callback: () => void);
  57374. /**
  57375. * An event triggered before rendering the scene
  57376. */
  57377. onBeforeRenderObservable: Observable<Layer>;
  57378. private _onBeforeRenderObserver;
  57379. /**
  57380. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57381. * The set callback will be triggered just before rendering the layer.
  57382. */
  57383. set onBeforeRender(callback: () => void);
  57384. /**
  57385. * An event triggered after rendering the scene
  57386. */
  57387. onAfterRenderObservable: Observable<Layer>;
  57388. private _onAfterRenderObserver;
  57389. /**
  57390. * Back compatibility with callback before the onAfterRenderObservable existed.
  57391. * The set callback will be triggered just after rendering the layer.
  57392. */
  57393. set onAfterRender(callback: () => void);
  57394. /**
  57395. * Instantiates a new layer.
  57396. * This represents a full screen 2d layer.
  57397. * This can be useful to display a picture in the background of your scene for instance.
  57398. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57399. * @param name Define the name of the layer in the scene
  57400. * @param imgUrl Define the url of the texture to display in the layer
  57401. * @param scene Define the scene the layer belongs to
  57402. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57403. * @param color Defines a color for the layer
  57404. */
  57405. constructor(
  57406. /**
  57407. * Define the name of the layer.
  57408. */
  57409. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57410. private _createIndexBuffer;
  57411. /** @hidden */
  57412. _rebuild(): void;
  57413. /**
  57414. * Renders the layer in the scene.
  57415. */
  57416. render(): void;
  57417. /**
  57418. * Disposes and releases the associated ressources.
  57419. */
  57420. dispose(): void;
  57421. }
  57422. }
  57423. declare module BABYLON {
  57424. /** @hidden */
  57425. export var lensFlarePixelShader: {
  57426. name: string;
  57427. shader: string;
  57428. };
  57429. }
  57430. declare module BABYLON {
  57431. /** @hidden */
  57432. export var lensFlareVertexShader: {
  57433. name: string;
  57434. shader: string;
  57435. };
  57436. }
  57437. declare module BABYLON {
  57438. /**
  57439. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57440. * It is usually composed of several `lensFlare`.
  57441. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57442. */
  57443. export class LensFlareSystem {
  57444. /**
  57445. * Define the name of the lens flare system
  57446. */
  57447. name: string;
  57448. /**
  57449. * List of lens flares used in this system.
  57450. */
  57451. lensFlares: LensFlare[];
  57452. /**
  57453. * Define a limit from the border the lens flare can be visible.
  57454. */
  57455. borderLimit: number;
  57456. /**
  57457. * Define a viewport border we do not want to see the lens flare in.
  57458. */
  57459. viewportBorder: number;
  57460. /**
  57461. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57462. */
  57463. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57464. /**
  57465. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57466. */
  57467. layerMask: number;
  57468. /**
  57469. * Define the id of the lens flare system in the scene.
  57470. * (equal to name by default)
  57471. */
  57472. id: string;
  57473. private _scene;
  57474. private _emitter;
  57475. private _vertexBuffers;
  57476. private _indexBuffer;
  57477. private _effect;
  57478. private _positionX;
  57479. private _positionY;
  57480. private _isEnabled;
  57481. /** @hidden */
  57482. static _SceneComponentInitialization: (scene: Scene) => void;
  57483. /**
  57484. * Instantiates a lens flare system.
  57485. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57486. * It is usually composed of several `lensFlare`.
  57487. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57488. * @param name Define the name of the lens flare system in the scene
  57489. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57490. * @param scene Define the scene the lens flare system belongs to
  57491. */
  57492. constructor(
  57493. /**
  57494. * Define the name of the lens flare system
  57495. */
  57496. name: string, emitter: any, scene: Scene);
  57497. /**
  57498. * Define if the lens flare system is enabled.
  57499. */
  57500. get isEnabled(): boolean;
  57501. set isEnabled(value: boolean);
  57502. /**
  57503. * Get the scene the effects belongs to.
  57504. * @returns the scene holding the lens flare system
  57505. */
  57506. getScene(): Scene;
  57507. /**
  57508. * Get the emitter of the lens flare system.
  57509. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57510. * @returns the emitter of the lens flare system
  57511. */
  57512. getEmitter(): any;
  57513. /**
  57514. * Set the emitter of the lens flare system.
  57515. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57516. * @param newEmitter Define the new emitter of the system
  57517. */
  57518. setEmitter(newEmitter: any): void;
  57519. /**
  57520. * Get the lens flare system emitter position.
  57521. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57522. * @returns the position
  57523. */
  57524. getEmitterPosition(): Vector3;
  57525. /**
  57526. * @hidden
  57527. */
  57528. computeEffectivePosition(globalViewport: Viewport): boolean;
  57529. /** @hidden */
  57530. _isVisible(): boolean;
  57531. /**
  57532. * @hidden
  57533. */
  57534. render(): boolean;
  57535. /**
  57536. * Dispose and release the lens flare with its associated resources.
  57537. */
  57538. dispose(): void;
  57539. /**
  57540. * Parse a lens flare system from a JSON repressentation
  57541. * @param parsedLensFlareSystem Define the JSON to parse
  57542. * @param scene Define the scene the parsed system should be instantiated in
  57543. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57544. * @returns the parsed system
  57545. */
  57546. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57547. /**
  57548. * Serialize the current Lens Flare System into a JSON representation.
  57549. * @returns the serialized JSON
  57550. */
  57551. serialize(): any;
  57552. }
  57553. }
  57554. declare module BABYLON {
  57555. /**
  57556. * This represents one of the lens effect in a `lensFlareSystem`.
  57557. * It controls one of the indiviual texture used in the effect.
  57558. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57559. */
  57560. export class LensFlare {
  57561. /**
  57562. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57563. */
  57564. size: number;
  57565. /**
  57566. * 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.
  57567. */
  57568. position: number;
  57569. /**
  57570. * Define the lens color.
  57571. */
  57572. color: Color3;
  57573. /**
  57574. * Define the lens texture.
  57575. */
  57576. texture: Nullable<Texture>;
  57577. /**
  57578. * Define the alpha mode to render this particular lens.
  57579. */
  57580. alphaMode: number;
  57581. private _system;
  57582. /**
  57583. * Creates a new Lens Flare.
  57584. * This represents one of the lens effect in a `lensFlareSystem`.
  57585. * It controls one of the indiviual texture used in the effect.
  57586. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57587. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  57588. * @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.
  57589. * @param color Define the lens color
  57590. * @param imgUrl Define the lens texture url
  57591. * @param system Define the `lensFlareSystem` this flare is part of
  57592. * @returns The newly created Lens Flare
  57593. */
  57594. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  57595. /**
  57596. * Instantiates a new Lens Flare.
  57597. * This represents one of the lens effect in a `lensFlareSystem`.
  57598. * It controls one of the indiviual texture used in the effect.
  57599. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57600. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  57601. * @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.
  57602. * @param color Define the lens color
  57603. * @param imgUrl Define the lens texture url
  57604. * @param system Define the `lensFlareSystem` this flare is part of
  57605. */
  57606. constructor(
  57607. /**
  57608. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57609. */
  57610. size: number,
  57611. /**
  57612. * 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.
  57613. */
  57614. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  57615. /**
  57616. * Dispose and release the lens flare with its associated resources.
  57617. */
  57618. dispose(): void;
  57619. }
  57620. }
  57621. declare module BABYLON {
  57622. interface AbstractScene {
  57623. /**
  57624. * The list of lens flare system added to the scene
  57625. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57626. */
  57627. lensFlareSystems: Array<LensFlareSystem>;
  57628. /**
  57629. * Removes the given lens flare system from this scene.
  57630. * @param toRemove The lens flare system to remove
  57631. * @returns The index of the removed lens flare system
  57632. */
  57633. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  57634. /**
  57635. * Adds the given lens flare system to this scene
  57636. * @param newLensFlareSystem The lens flare system to add
  57637. */
  57638. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  57639. /**
  57640. * Gets a lens flare system using its name
  57641. * @param name defines the name to look for
  57642. * @returns the lens flare system or null if not found
  57643. */
  57644. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  57645. /**
  57646. * Gets a lens flare system using its id
  57647. * @param id defines the id to look for
  57648. * @returns the lens flare system or null if not found
  57649. */
  57650. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  57651. }
  57652. /**
  57653. * Defines the lens flare scene component responsible to manage any lens flares
  57654. * in a given scene.
  57655. */
  57656. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  57657. /**
  57658. * The component name helpfull to identify the component in the list of scene components.
  57659. */
  57660. readonly name: string;
  57661. /**
  57662. * The scene the component belongs to.
  57663. */
  57664. scene: Scene;
  57665. /**
  57666. * Creates a new instance of the component for the given scene
  57667. * @param scene Defines the scene to register the component in
  57668. */
  57669. constructor(scene: Scene);
  57670. /**
  57671. * Registers the component in a given scene
  57672. */
  57673. register(): void;
  57674. /**
  57675. * Rebuilds the elements related to this component in case of
  57676. * context lost for instance.
  57677. */
  57678. rebuild(): void;
  57679. /**
  57680. * Adds all the elements from the container to the scene
  57681. * @param container the container holding the elements
  57682. */
  57683. addFromContainer(container: AbstractScene): void;
  57684. /**
  57685. * Removes all the elements in the container from the scene
  57686. * @param container contains the elements to remove
  57687. * @param dispose if the removed element should be disposed (default: false)
  57688. */
  57689. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57690. /**
  57691. * Serializes the component data to the specified json object
  57692. * @param serializationObject The object to serialize to
  57693. */
  57694. serialize(serializationObject: any): void;
  57695. /**
  57696. * Disposes the component and the associated ressources.
  57697. */
  57698. dispose(): void;
  57699. private _draw;
  57700. }
  57701. }
  57702. declare module BABYLON {
  57703. /** @hidden */
  57704. export var depthPixelShader: {
  57705. name: string;
  57706. shader: string;
  57707. };
  57708. }
  57709. declare module BABYLON {
  57710. /** @hidden */
  57711. export var depthVertexShader: {
  57712. name: string;
  57713. shader: string;
  57714. };
  57715. }
  57716. declare module BABYLON {
  57717. /**
  57718. * This represents a depth renderer in Babylon.
  57719. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57720. */
  57721. export class DepthRenderer {
  57722. private _scene;
  57723. private _depthMap;
  57724. private _effect;
  57725. private readonly _storeNonLinearDepth;
  57726. private readonly _clearColor;
  57727. /** Get if the depth renderer is using packed depth or not */
  57728. readonly isPacked: boolean;
  57729. private _cachedDefines;
  57730. private _camera;
  57731. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  57732. enabled: boolean;
  57733. /**
  57734. * Specifiess that the depth renderer will only be used within
  57735. * the camera it is created for.
  57736. * This can help forcing its rendering during the camera processing.
  57737. */
  57738. useOnlyInActiveCamera: boolean;
  57739. /** @hidden */
  57740. static _SceneComponentInitialization: (scene: Scene) => void;
  57741. /**
  57742. * Instantiates a depth renderer
  57743. * @param scene The scene the renderer belongs to
  57744. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57745. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57746. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57747. */
  57748. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57749. /**
  57750. * Creates the depth rendering effect and checks if the effect is ready.
  57751. * @param subMesh The submesh to be used to render the depth map of
  57752. * @param useInstances If multiple world instances should be used
  57753. * @returns if the depth renderer is ready to render the depth map
  57754. */
  57755. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57756. /**
  57757. * Gets the texture which the depth map will be written to.
  57758. * @returns The depth map texture
  57759. */
  57760. getDepthMap(): RenderTargetTexture;
  57761. /**
  57762. * Disposes of the depth renderer.
  57763. */
  57764. dispose(): void;
  57765. }
  57766. }
  57767. declare module BABYLON {
  57768. /** @hidden */
  57769. export var minmaxReduxPixelShader: {
  57770. name: string;
  57771. shader: string;
  57772. };
  57773. }
  57774. declare module BABYLON {
  57775. /**
  57776. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57777. * and maximum values from all values of the texture.
  57778. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57779. * The source values are read from the red channel of the texture.
  57780. */
  57781. export class MinMaxReducer {
  57782. /**
  57783. * Observable triggered when the computation has been performed
  57784. */
  57785. onAfterReductionPerformed: Observable<{
  57786. min: number;
  57787. max: number;
  57788. }>;
  57789. protected _camera: Camera;
  57790. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57791. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57792. protected _postProcessManager: PostProcessManager;
  57793. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57794. protected _forceFullscreenViewport: boolean;
  57795. /**
  57796. * Creates a min/max reducer
  57797. * @param camera The camera to use for the post processes
  57798. */
  57799. constructor(camera: Camera);
  57800. /**
  57801. * Gets the texture used to read the values from.
  57802. */
  57803. get sourceTexture(): Nullable<RenderTargetTexture>;
  57804. /**
  57805. * Sets the source texture to read the values from.
  57806. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57807. * because in such textures '1' value must not be taken into account to compute the maximum
  57808. * as this value is used to clear the texture.
  57809. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57810. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57811. * @param depthRedux Indicates if the texture is a depth texture or not
  57812. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57813. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57814. */
  57815. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57816. /**
  57817. * Defines the refresh rate of the computation.
  57818. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57819. */
  57820. get refreshRate(): number;
  57821. set refreshRate(value: number);
  57822. protected _activated: boolean;
  57823. /**
  57824. * Gets the activation status of the reducer
  57825. */
  57826. get activated(): boolean;
  57827. /**
  57828. * Activates the reduction computation.
  57829. * When activated, the observers registered in onAfterReductionPerformed are
  57830. * called after the compuation is performed
  57831. */
  57832. activate(): void;
  57833. /**
  57834. * Deactivates the reduction computation.
  57835. */
  57836. deactivate(): void;
  57837. /**
  57838. * Disposes the min/max reducer
  57839. * @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.
  57840. */
  57841. dispose(disposeAll?: boolean): void;
  57842. }
  57843. }
  57844. declare module BABYLON {
  57845. /**
  57846. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57847. */
  57848. export class DepthReducer extends MinMaxReducer {
  57849. private _depthRenderer;
  57850. private _depthRendererId;
  57851. /**
  57852. * Gets the depth renderer used for the computation.
  57853. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57854. */
  57855. get depthRenderer(): Nullable<DepthRenderer>;
  57856. /**
  57857. * Creates a depth reducer
  57858. * @param camera The camera used to render the depth texture
  57859. */
  57860. constructor(camera: Camera);
  57861. /**
  57862. * Sets the depth renderer to use to generate the depth map
  57863. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57864. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57865. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57866. */
  57867. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57868. /** @hidden */
  57869. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57870. /**
  57871. * Activates the reduction computation.
  57872. * When activated, the observers registered in onAfterReductionPerformed are
  57873. * called after the compuation is performed
  57874. */
  57875. activate(): void;
  57876. /**
  57877. * Deactivates the reduction computation.
  57878. */
  57879. deactivate(): void;
  57880. /**
  57881. * Disposes the depth reducer
  57882. * @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.
  57883. */
  57884. dispose(disposeAll?: boolean): void;
  57885. }
  57886. }
  57887. declare module BABYLON {
  57888. /**
  57889. * A CSM implementation allowing casting shadows on large scenes.
  57890. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57891. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57892. */
  57893. export class CascadedShadowGenerator extends ShadowGenerator {
  57894. private static readonly frustumCornersNDCSpace;
  57895. /**
  57896. * Name of the CSM class
  57897. */
  57898. static CLASSNAME: string;
  57899. /**
  57900. * Defines the default number of cascades used by the CSM.
  57901. */
  57902. static readonly DEFAULT_CASCADES_COUNT: number;
  57903. /**
  57904. * Defines the minimum number of cascades used by the CSM.
  57905. */
  57906. static readonly MIN_CASCADES_COUNT: number;
  57907. /**
  57908. * Defines the maximum number of cascades used by the CSM.
  57909. */
  57910. static readonly MAX_CASCADES_COUNT: number;
  57911. protected _validateFilter(filter: number): number;
  57912. /**
  57913. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57914. */
  57915. penumbraDarkness: number;
  57916. private _numCascades;
  57917. /**
  57918. * Gets or set the number of cascades used by the CSM.
  57919. */
  57920. get numCascades(): number;
  57921. set numCascades(value: number);
  57922. /**
  57923. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57924. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  57925. */
  57926. stabilizeCascades: boolean;
  57927. private _freezeShadowCastersBoundingInfo;
  57928. private _freezeShadowCastersBoundingInfoObservable;
  57929. /**
  57930. * Enables or disables the shadow casters bounding info computation.
  57931. * If your shadow casters don't move, you can disable this feature.
  57932. * If it is enabled, the bounding box computation is done every frame.
  57933. */
  57934. get freezeShadowCastersBoundingInfo(): boolean;
  57935. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57936. private _scbiMin;
  57937. private _scbiMax;
  57938. protected _computeShadowCastersBoundingInfo(): void;
  57939. protected _shadowCastersBoundingInfo: BoundingInfo;
  57940. /**
  57941. * Gets or sets the shadow casters bounding info.
  57942. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57943. * so that the system won't overwrite the bounds you provide
  57944. */
  57945. get shadowCastersBoundingInfo(): BoundingInfo;
  57946. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57947. protected _breaksAreDirty: boolean;
  57948. protected _minDistance: number;
  57949. protected _maxDistance: number;
  57950. /**
  57951. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57952. *
  57953. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57954. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57955. * @param min minimal distance for the breaks (default to 0.)
  57956. * @param max maximal distance for the breaks (default to 1.)
  57957. */
  57958. setMinMaxDistance(min: number, max: number): void;
  57959. /** Gets the minimal distance used in the cascade break computation */
  57960. get minDistance(): number;
  57961. /** Gets the maximal distance used in the cascade break computation */
  57962. get maxDistance(): number;
  57963. /**
  57964. * Gets the class name of that object
  57965. * @returns "CascadedShadowGenerator"
  57966. */
  57967. getClassName(): string;
  57968. private _cascadeMinExtents;
  57969. private _cascadeMaxExtents;
  57970. /**
  57971. * Gets a cascade minimum extents
  57972. * @param cascadeIndex index of the cascade
  57973. * @returns the minimum cascade extents
  57974. */
  57975. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57976. /**
  57977. * Gets a cascade maximum extents
  57978. * @param cascadeIndex index of the cascade
  57979. * @returns the maximum cascade extents
  57980. */
  57981. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57982. private _cascades;
  57983. private _currentLayer;
  57984. private _viewSpaceFrustumsZ;
  57985. private _viewMatrices;
  57986. private _projectionMatrices;
  57987. private _transformMatrices;
  57988. private _transformMatricesAsArray;
  57989. private _frustumLengths;
  57990. private _lightSizeUVCorrection;
  57991. private _depthCorrection;
  57992. private _frustumCornersWorldSpace;
  57993. private _frustumCenter;
  57994. private _shadowCameraPos;
  57995. private _shadowMaxZ;
  57996. /**
  57997. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57998. * It defaults to camera.maxZ
  57999. */
  58000. get shadowMaxZ(): number;
  58001. /**
  58002. * Sets the shadow max z distance.
  58003. */
  58004. set shadowMaxZ(value: number);
  58005. protected _debug: boolean;
  58006. /**
  58007. * Gets or sets the debug flag.
  58008. * When enabled, the cascades are materialized by different colors on the screen.
  58009. */
  58010. get debug(): boolean;
  58011. set debug(dbg: boolean);
  58012. private _depthClamp;
  58013. /**
  58014. * Gets or sets the depth clamping value.
  58015. *
  58016. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58017. * to account for the shadow casters far away.
  58018. *
  58019. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58020. */
  58021. get depthClamp(): boolean;
  58022. set depthClamp(value: boolean);
  58023. private _cascadeBlendPercentage;
  58024. /**
  58025. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58026. * It defaults to 0.1 (10% blending).
  58027. */
  58028. get cascadeBlendPercentage(): number;
  58029. set cascadeBlendPercentage(value: number);
  58030. private _lambda;
  58031. /**
  58032. * Gets or set the lambda parameter.
  58033. * This parameter is used to split the camera frustum and create the cascades.
  58034. * 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.
  58035. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58036. */
  58037. get lambda(): number;
  58038. set lambda(value: number);
  58039. /**
  58040. * Gets the view matrix corresponding to a given cascade
  58041. * @param cascadeNum cascade to retrieve the view matrix from
  58042. * @returns the cascade view matrix
  58043. */
  58044. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58045. /**
  58046. * Gets the projection matrix corresponding to a given cascade
  58047. * @param cascadeNum cascade to retrieve the projection matrix from
  58048. * @returns the cascade projection matrix
  58049. */
  58050. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58051. /**
  58052. * Gets the transformation matrix corresponding to a given cascade
  58053. * @param cascadeNum cascade to retrieve the transformation matrix from
  58054. * @returns the cascade transformation matrix
  58055. */
  58056. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58057. private _depthRenderer;
  58058. /**
  58059. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58060. *
  58061. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58062. *
  58063. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58064. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58065. * @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
  58066. */
  58067. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58068. private _depthReducer;
  58069. private _autoCalcDepthBounds;
  58070. /**
  58071. * Gets or sets the autoCalcDepthBounds property.
  58072. *
  58073. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58074. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58075. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58076. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58077. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58078. */
  58079. get autoCalcDepthBounds(): boolean;
  58080. set autoCalcDepthBounds(value: boolean);
  58081. /**
  58082. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58083. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58084. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58085. * for setting the refresh rate on the renderer yourself!
  58086. */
  58087. get autoCalcDepthBoundsRefreshRate(): number;
  58088. set autoCalcDepthBoundsRefreshRate(value: number);
  58089. /**
  58090. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58091. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58092. * you change the camera near/far planes!
  58093. */
  58094. splitFrustum(): void;
  58095. private _splitFrustum;
  58096. private _computeMatrices;
  58097. private _computeFrustumInWorldSpace;
  58098. private _computeCascadeFrustum;
  58099. /**
  58100. * Support test.
  58101. */
  58102. static get IsSupported(): boolean;
  58103. /** @hidden */
  58104. static _SceneComponentInitialization: (scene: Scene) => void;
  58105. /**
  58106. * Creates a Cascaded Shadow Generator object.
  58107. * A ShadowGenerator is the required tool to use the shadows.
  58108. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58109. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58110. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58111. * @param light The directional light object generating the shadows.
  58112. * @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.
  58113. */
  58114. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58115. protected _initializeGenerator(): void;
  58116. protected _createTargetRenderTexture(): void;
  58117. protected _initializeShadowMap(): void;
  58118. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58119. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58120. /**
  58121. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58122. * @param defines Defines of the material we want to update
  58123. * @param lightIndex Index of the light in the enabled light list of the material
  58124. */
  58125. prepareDefines(defines: any, lightIndex: number): void;
  58126. /**
  58127. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58128. * defined in the generator but impacting the effect).
  58129. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58130. * @param effect The effect we are binfing the information for
  58131. */
  58132. bindShadowLight(lightIndex: string, effect: Effect): void;
  58133. /**
  58134. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58135. * (eq to view projection * shadow projection matrices)
  58136. * @returns The transform matrix used to create the shadow map
  58137. */
  58138. getTransformMatrix(): Matrix;
  58139. /**
  58140. * Disposes the ShadowGenerator.
  58141. * Returns nothing.
  58142. */
  58143. dispose(): void;
  58144. /**
  58145. * Serializes the shadow generator setup to a json object.
  58146. * @returns The serialized JSON object
  58147. */
  58148. serialize(): any;
  58149. /**
  58150. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58151. * @param parsedShadowGenerator The JSON object to parse
  58152. * @param scene The scene to create the shadow map for
  58153. * @returns The parsed shadow generator
  58154. */
  58155. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58156. }
  58157. }
  58158. declare module BABYLON {
  58159. /**
  58160. * Defines the shadow generator component responsible to manage any shadow generators
  58161. * in a given scene.
  58162. */
  58163. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58164. /**
  58165. * The component name helpfull to identify the component in the list of scene components.
  58166. */
  58167. readonly name: string;
  58168. /**
  58169. * The scene the component belongs to.
  58170. */
  58171. scene: Scene;
  58172. /**
  58173. * Creates a new instance of the component for the given scene
  58174. * @param scene Defines the scene to register the component in
  58175. */
  58176. constructor(scene: Scene);
  58177. /**
  58178. * Registers the component in a given scene
  58179. */
  58180. register(): void;
  58181. /**
  58182. * Rebuilds the elements related to this component in case of
  58183. * context lost for instance.
  58184. */
  58185. rebuild(): void;
  58186. /**
  58187. * Serializes the component data to the specified json object
  58188. * @param serializationObject The object to serialize to
  58189. */
  58190. serialize(serializationObject: any): void;
  58191. /**
  58192. * Adds all the elements from the container to the scene
  58193. * @param container the container holding the elements
  58194. */
  58195. addFromContainer(container: AbstractScene): void;
  58196. /**
  58197. * Removes all the elements in the container from the scene
  58198. * @param container contains the elements to remove
  58199. * @param dispose if the removed element should be disposed (default: false)
  58200. */
  58201. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58202. /**
  58203. * Rebuilds the elements related to this component in case of
  58204. * context lost for instance.
  58205. */
  58206. dispose(): void;
  58207. private _gatherRenderTargets;
  58208. }
  58209. }
  58210. declare module BABYLON {
  58211. /**
  58212. * A point light is a light defined by an unique point in world space.
  58213. * The light is emitted in every direction from this point.
  58214. * A good example of a point light is a standard light bulb.
  58215. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58216. */
  58217. export class PointLight extends ShadowLight {
  58218. private _shadowAngle;
  58219. /**
  58220. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58221. * This specifies what angle the shadow will use to be created.
  58222. *
  58223. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58224. */
  58225. get shadowAngle(): number;
  58226. /**
  58227. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58228. * This specifies what angle the shadow will use to be created.
  58229. *
  58230. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58231. */
  58232. set shadowAngle(value: number);
  58233. /**
  58234. * Gets the direction if it has been set.
  58235. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58236. */
  58237. get direction(): Vector3;
  58238. /**
  58239. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58240. */
  58241. set direction(value: Vector3);
  58242. /**
  58243. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58244. * A PointLight emits the light in every direction.
  58245. * It can cast shadows.
  58246. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58247. * ```javascript
  58248. * var pointLight = new PointLight("pl", camera.position, scene);
  58249. * ```
  58250. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58251. * @param name The light friendly name
  58252. * @param position The position of the point light in the scene
  58253. * @param scene The scene the lights belongs to
  58254. */
  58255. constructor(name: string, position: Vector3, scene: Scene);
  58256. /**
  58257. * Returns the string "PointLight"
  58258. * @returns the class name
  58259. */
  58260. getClassName(): string;
  58261. /**
  58262. * Returns the integer 0.
  58263. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58264. */
  58265. getTypeID(): number;
  58266. /**
  58267. * Specifies wether or not the shadowmap should be a cube texture.
  58268. * @returns true if the shadowmap needs to be a cube texture.
  58269. */
  58270. needCube(): boolean;
  58271. /**
  58272. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58273. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58274. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58275. */
  58276. getShadowDirection(faceIndex?: number): Vector3;
  58277. /**
  58278. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58279. * - fov = PI / 2
  58280. * - aspect ratio : 1.0
  58281. * - z-near and far equal to the active camera minZ and maxZ.
  58282. * Returns the PointLight.
  58283. */
  58284. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58285. protected _buildUniformLayout(): void;
  58286. /**
  58287. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58288. * @param effect The effect to update
  58289. * @param lightIndex The index of the light in the effect to update
  58290. * @returns The point light
  58291. */
  58292. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58293. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58294. /**
  58295. * Prepares the list of defines specific to the light type.
  58296. * @param defines the list of defines
  58297. * @param lightIndex defines the index of the light for the effect
  58298. */
  58299. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58300. }
  58301. }
  58302. declare module BABYLON {
  58303. /**
  58304. * Header information of HDR texture files.
  58305. */
  58306. export interface HDRInfo {
  58307. /**
  58308. * The height of the texture in pixels.
  58309. */
  58310. height: number;
  58311. /**
  58312. * The width of the texture in pixels.
  58313. */
  58314. width: number;
  58315. /**
  58316. * The index of the beginning of the data in the binary file.
  58317. */
  58318. dataPosition: number;
  58319. }
  58320. /**
  58321. * This groups tools to convert HDR texture to native colors array.
  58322. */
  58323. export class HDRTools {
  58324. private static Ldexp;
  58325. private static Rgbe2float;
  58326. private static readStringLine;
  58327. /**
  58328. * Reads header information from an RGBE texture stored in a native array.
  58329. * More information on this format are available here:
  58330. * https://en.wikipedia.org/wiki/RGBE_image_format
  58331. *
  58332. * @param uint8array The binary file stored in native array.
  58333. * @return The header information.
  58334. */
  58335. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58336. /**
  58337. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58338. * This RGBE texture needs to store the information as a panorama.
  58339. *
  58340. * More information on this format are available here:
  58341. * https://en.wikipedia.org/wiki/RGBE_image_format
  58342. *
  58343. * @param buffer The binary file stored in an array buffer.
  58344. * @param size The expected size of the extracted cubemap.
  58345. * @return The Cube Map information.
  58346. */
  58347. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58348. /**
  58349. * Returns the pixels data extracted from an RGBE texture.
  58350. * This pixels will be stored left to right up to down in the R G B order in one array.
  58351. *
  58352. * More information on this format are available here:
  58353. * https://en.wikipedia.org/wiki/RGBE_image_format
  58354. *
  58355. * @param uint8array The binary file stored in an array buffer.
  58356. * @param hdrInfo The header information of the file.
  58357. * @return The pixels data in RGB right to left up to down order.
  58358. */
  58359. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58360. private static RGBE_ReadPixels_RLE;
  58361. }
  58362. }
  58363. declare module BABYLON {
  58364. /**
  58365. * Effect Render Options
  58366. */
  58367. export interface IEffectRendererOptions {
  58368. /**
  58369. * Defines the vertices positions.
  58370. */
  58371. positions?: number[];
  58372. /**
  58373. * Defines the indices.
  58374. */
  58375. indices?: number[];
  58376. }
  58377. /**
  58378. * Helper class to render one or more effects.
  58379. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58380. */
  58381. export class EffectRenderer {
  58382. private engine;
  58383. private static _DefaultOptions;
  58384. private _vertexBuffers;
  58385. private _indexBuffer;
  58386. private _fullscreenViewport;
  58387. /**
  58388. * Creates an effect renderer
  58389. * @param engine the engine to use for rendering
  58390. * @param options defines the options of the effect renderer
  58391. */
  58392. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58393. /**
  58394. * Sets the current viewport in normalized coordinates 0-1
  58395. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58396. */
  58397. setViewport(viewport?: Viewport): void;
  58398. /**
  58399. * Binds the embedded attributes buffer to the effect.
  58400. * @param effect Defines the effect to bind the attributes for
  58401. */
  58402. bindBuffers(effect: Effect): void;
  58403. /**
  58404. * Sets the current effect wrapper to use during draw.
  58405. * The effect needs to be ready before calling this api.
  58406. * This also sets the default full screen position attribute.
  58407. * @param effectWrapper Defines the effect to draw with
  58408. */
  58409. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58410. /**
  58411. * Restores engine states
  58412. */
  58413. restoreStates(): void;
  58414. /**
  58415. * Draws a full screen quad.
  58416. */
  58417. draw(): void;
  58418. private isRenderTargetTexture;
  58419. /**
  58420. * renders one or more effects to a specified texture
  58421. * @param effectWrapper the effect to renderer
  58422. * @param outputTexture texture to draw to, if null it will render to the screen.
  58423. */
  58424. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58425. /**
  58426. * Disposes of the effect renderer
  58427. */
  58428. dispose(): void;
  58429. }
  58430. /**
  58431. * Options to create an EffectWrapper
  58432. */
  58433. interface EffectWrapperCreationOptions {
  58434. /**
  58435. * Engine to use to create the effect
  58436. */
  58437. engine: ThinEngine;
  58438. /**
  58439. * Fragment shader for the effect
  58440. */
  58441. fragmentShader: string;
  58442. /**
  58443. * Use the shader store instead of direct source code
  58444. */
  58445. useShaderStore?: boolean;
  58446. /**
  58447. * Vertex shader for the effect
  58448. */
  58449. vertexShader?: string;
  58450. /**
  58451. * Attributes to use in the shader
  58452. */
  58453. attributeNames?: Array<string>;
  58454. /**
  58455. * Uniforms to use in the shader
  58456. */
  58457. uniformNames?: Array<string>;
  58458. /**
  58459. * Texture sampler names to use in the shader
  58460. */
  58461. samplerNames?: Array<string>;
  58462. /**
  58463. * Defines to use in the shader
  58464. */
  58465. defines?: Array<string>;
  58466. /**
  58467. * Callback when effect is compiled
  58468. */
  58469. onCompiled?: Nullable<(effect: Effect) => void>;
  58470. /**
  58471. * The friendly name of the effect displayed in Spector.
  58472. */
  58473. name?: string;
  58474. }
  58475. /**
  58476. * Wraps an effect to be used for rendering
  58477. */
  58478. export class EffectWrapper {
  58479. /**
  58480. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58481. */
  58482. onApplyObservable: Observable<{}>;
  58483. /**
  58484. * The underlying effect
  58485. */
  58486. effect: Effect;
  58487. /**
  58488. * Creates an effect to be renderer
  58489. * @param creationOptions options to create the effect
  58490. */
  58491. constructor(creationOptions: EffectWrapperCreationOptions);
  58492. /**
  58493. * Disposes of the effect wrapper
  58494. */
  58495. dispose(): void;
  58496. }
  58497. }
  58498. declare module BABYLON {
  58499. /** @hidden */
  58500. export var hdrFilteringVertexShader: {
  58501. name: string;
  58502. shader: string;
  58503. };
  58504. }
  58505. declare module BABYLON {
  58506. /** @hidden */
  58507. export var hdrFilteringPixelShader: {
  58508. name: string;
  58509. shader: string;
  58510. };
  58511. }
  58512. declare module BABYLON {
  58513. /**
  58514. * Options for texture filtering
  58515. */
  58516. interface IHDRFilteringOptions {
  58517. /**
  58518. * Scales pixel intensity for the input HDR map.
  58519. */
  58520. hdrScale?: number;
  58521. /**
  58522. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58523. */
  58524. quality?: number;
  58525. }
  58526. /**
  58527. * Filters HDR maps to get correct renderings of PBR reflections
  58528. */
  58529. export class HDRFiltering {
  58530. private _engine;
  58531. private _effectRenderer;
  58532. private _effectWrapper;
  58533. private _lodGenerationOffset;
  58534. private _lodGenerationScale;
  58535. /**
  58536. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58537. * you care about baking speed.
  58538. */
  58539. quality: number;
  58540. /**
  58541. * Scales pixel intensity for the input HDR map.
  58542. */
  58543. hdrScale: number;
  58544. /**
  58545. * Instantiates HDR filter for reflection maps
  58546. *
  58547. * @param engine Thin engine
  58548. * @param options Options
  58549. */
  58550. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58551. private _createRenderTarget;
  58552. private _prefilterInternal;
  58553. private _createEffect;
  58554. /**
  58555. * Get a value indicating if the filter is ready to be used
  58556. * @param texture Texture to filter
  58557. * @returns true if the filter is ready
  58558. */
  58559. isReady(texture: BaseTexture): boolean;
  58560. /**
  58561. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58562. * Prefiltering will be invoked at the end of next rendering pass.
  58563. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58564. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58565. * @param texture Texture to filter
  58566. * @param onFinished Callback when filtering is done
  58567. * @return Promise called when prefiltering is done
  58568. */
  58569. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  58570. }
  58571. }
  58572. declare module BABYLON {
  58573. /**
  58574. * This represents a texture coming from an HDR input.
  58575. *
  58576. * The only supported format is currently panorama picture stored in RGBE format.
  58577. * Example of such files can be found on HDRLib: http://hdrlib.com/
  58578. */
  58579. export class HDRCubeTexture extends BaseTexture {
  58580. private static _facesMapping;
  58581. private _generateHarmonics;
  58582. private _noMipmap;
  58583. private _prefilterOnLoad;
  58584. private _textureMatrix;
  58585. private _size;
  58586. private _onLoad;
  58587. private _onError;
  58588. /**
  58589. * The texture URL.
  58590. */
  58591. url: string;
  58592. /**
  58593. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  58594. */
  58595. coordinatesMode: number;
  58596. protected _isBlocking: boolean;
  58597. /**
  58598. * Sets wether or not the texture is blocking during loading.
  58599. */
  58600. set isBlocking(value: boolean);
  58601. /**
  58602. * Gets wether or not the texture is blocking during loading.
  58603. */
  58604. get isBlocking(): boolean;
  58605. protected _rotationY: number;
  58606. /**
  58607. * Sets texture matrix rotation angle around Y axis in radians.
  58608. */
  58609. set rotationY(value: number);
  58610. /**
  58611. * Gets texture matrix rotation angle around Y axis radians.
  58612. */
  58613. get rotationY(): number;
  58614. /**
  58615. * Gets or sets the center of the bounding box associated with the cube texture
  58616. * It must define where the camera used to render the texture was set
  58617. */
  58618. boundingBoxPosition: Vector3;
  58619. private _boundingBoxSize;
  58620. /**
  58621. * Gets or sets the size of the bounding box associated with the cube texture
  58622. * When defined, the cubemap will switch to local mode
  58623. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58624. * @example https://www.babylonjs-playground.com/#RNASML
  58625. */
  58626. set boundingBoxSize(value: Vector3);
  58627. get boundingBoxSize(): Vector3;
  58628. /**
  58629. * Instantiates an HDRTexture from the following parameters.
  58630. *
  58631. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  58632. * @param sceneOrEngine The scene or engine the texture will be used in
  58633. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58634. * @param noMipmap Forces to not generate the mipmap if true
  58635. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  58636. * @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)
  58637. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  58638. */
  58639. 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>);
  58640. /**
  58641. * Get the current class name of the texture useful for serialization or dynamic coding.
  58642. * @returns "HDRCubeTexture"
  58643. */
  58644. getClassName(): string;
  58645. /**
  58646. * Occurs when the file is raw .hdr file.
  58647. */
  58648. private loadTexture;
  58649. clone(): HDRCubeTexture;
  58650. delayLoad(): void;
  58651. /**
  58652. * Get the texture reflection matrix used to rotate/transform the reflection.
  58653. * @returns the reflection matrix
  58654. */
  58655. getReflectionTextureMatrix(): Matrix;
  58656. /**
  58657. * Set the texture reflection matrix used to rotate/transform the reflection.
  58658. * @param value Define the reflection matrix to set
  58659. */
  58660. setReflectionTextureMatrix(value: Matrix): void;
  58661. /**
  58662. * Parses a JSON representation of an HDR Texture in order to create the texture
  58663. * @param parsedTexture Define the JSON representation
  58664. * @param scene Define the scene the texture should be created in
  58665. * @param rootUrl Define the root url in case we need to load relative dependencies
  58666. * @returns the newly created texture after parsing
  58667. */
  58668. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  58669. serialize(): any;
  58670. }
  58671. }
  58672. declare module BABYLON {
  58673. /**
  58674. * Class used to control physics engine
  58675. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58676. */
  58677. export class PhysicsEngine implements IPhysicsEngine {
  58678. private _physicsPlugin;
  58679. /**
  58680. * Global value used to control the smallest number supported by the simulation
  58681. */
  58682. static Epsilon: number;
  58683. private _impostors;
  58684. private _joints;
  58685. private _subTimeStep;
  58686. /**
  58687. * Gets the gravity vector used by the simulation
  58688. */
  58689. gravity: Vector3;
  58690. /**
  58691. * Factory used to create the default physics plugin.
  58692. * @returns The default physics plugin
  58693. */
  58694. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  58695. /**
  58696. * Creates a new Physics Engine
  58697. * @param gravity defines the gravity vector used by the simulation
  58698. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  58699. */
  58700. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  58701. /**
  58702. * Sets the gravity vector used by the simulation
  58703. * @param gravity defines the gravity vector to use
  58704. */
  58705. setGravity(gravity: Vector3): void;
  58706. /**
  58707. * Set the time step of the physics engine.
  58708. * Default is 1/60.
  58709. * To slow it down, enter 1/600 for example.
  58710. * To speed it up, 1/30
  58711. * @param newTimeStep defines the new timestep to apply to this world.
  58712. */
  58713. setTimeStep(newTimeStep?: number): void;
  58714. /**
  58715. * Get the time step of the physics engine.
  58716. * @returns the current time step
  58717. */
  58718. getTimeStep(): number;
  58719. /**
  58720. * Set the sub time step of the physics engine.
  58721. * Default is 0 meaning there is no sub steps
  58722. * To increase physics resolution precision, set a small value (like 1 ms)
  58723. * @param subTimeStep defines the new sub timestep used for physics resolution.
  58724. */
  58725. setSubTimeStep(subTimeStep?: number): void;
  58726. /**
  58727. * Get the sub time step of the physics engine.
  58728. * @returns the current sub time step
  58729. */
  58730. getSubTimeStep(): number;
  58731. /**
  58732. * Release all resources
  58733. */
  58734. dispose(): void;
  58735. /**
  58736. * Gets the name of the current physics plugin
  58737. * @returns the name of the plugin
  58738. */
  58739. getPhysicsPluginName(): string;
  58740. /**
  58741. * Adding a new impostor for the impostor tracking.
  58742. * This will be done by the impostor itself.
  58743. * @param impostor the impostor to add
  58744. */
  58745. addImpostor(impostor: PhysicsImpostor): void;
  58746. /**
  58747. * Remove an impostor from the engine.
  58748. * This impostor and its mesh will not longer be updated by the physics engine.
  58749. * @param impostor the impostor to remove
  58750. */
  58751. removeImpostor(impostor: PhysicsImpostor): void;
  58752. /**
  58753. * Add a joint to the physics engine
  58754. * @param mainImpostor defines the main impostor to which the joint is added.
  58755. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  58756. * @param joint defines the joint that will connect both impostors.
  58757. */
  58758. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58759. /**
  58760. * Removes a joint from the simulation
  58761. * @param mainImpostor defines the impostor used with the joint
  58762. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  58763. * @param joint defines the joint to remove
  58764. */
  58765. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  58766. /**
  58767. * Called by the scene. No need to call it.
  58768. * @param delta defines the timespam between frames
  58769. */
  58770. _step(delta: number): void;
  58771. /**
  58772. * Gets the current plugin used to run the simulation
  58773. * @returns current plugin
  58774. */
  58775. getPhysicsPlugin(): IPhysicsEnginePlugin;
  58776. /**
  58777. * Gets the list of physic impostors
  58778. * @returns an array of PhysicsImpostor
  58779. */
  58780. getImpostors(): Array<PhysicsImpostor>;
  58781. /**
  58782. * Gets the impostor for a physics enabled object
  58783. * @param object defines the object impersonated by the impostor
  58784. * @returns the PhysicsImpostor or null if not found
  58785. */
  58786. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  58787. /**
  58788. * Gets the impostor for a physics body object
  58789. * @param body defines physics body used by the impostor
  58790. * @returns the PhysicsImpostor or null if not found
  58791. */
  58792. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  58793. /**
  58794. * Does a raycast in the physics world
  58795. * @param from when should the ray start?
  58796. * @param to when should the ray end?
  58797. * @returns PhysicsRaycastResult
  58798. */
  58799. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58800. }
  58801. }
  58802. declare module BABYLON {
  58803. /** @hidden */
  58804. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  58805. private _useDeltaForWorldStep;
  58806. world: any;
  58807. name: string;
  58808. private _physicsMaterials;
  58809. private _fixedTimeStep;
  58810. private _cannonRaycastResult;
  58811. private _raycastResult;
  58812. private _physicsBodysToRemoveAfterStep;
  58813. private _firstFrame;
  58814. BJSCANNON: any;
  58815. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  58816. setGravity(gravity: Vector3): void;
  58817. setTimeStep(timeStep: number): void;
  58818. getTimeStep(): number;
  58819. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58820. private _removeMarkedPhysicsBodiesFromWorld;
  58821. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58822. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58823. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58824. private _processChildMeshes;
  58825. removePhysicsBody(impostor: PhysicsImpostor): void;
  58826. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58827. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58828. private _addMaterial;
  58829. private _checkWithEpsilon;
  58830. private _createShape;
  58831. private _createHeightmap;
  58832. private _minus90X;
  58833. private _plus90X;
  58834. private _tmpPosition;
  58835. private _tmpDeltaPosition;
  58836. private _tmpUnityRotation;
  58837. private _updatePhysicsBodyTransformation;
  58838. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58839. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58840. isSupported(): boolean;
  58841. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58842. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58843. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58844. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58845. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58846. getBodyMass(impostor: PhysicsImpostor): number;
  58847. getBodyFriction(impostor: PhysicsImpostor): number;
  58848. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58849. getBodyRestitution(impostor: PhysicsImpostor): number;
  58850. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58851. sleepBody(impostor: PhysicsImpostor): void;
  58852. wakeUpBody(impostor: PhysicsImpostor): void;
  58853. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  58854. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58855. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58856. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58857. getRadius(impostor: PhysicsImpostor): number;
  58858. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58859. dispose(): void;
  58860. private _extendNamespace;
  58861. /**
  58862. * Does a raycast in the physics world
  58863. * @param from when should the ray start?
  58864. * @param to when should the ray end?
  58865. * @returns PhysicsRaycastResult
  58866. */
  58867. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58868. }
  58869. }
  58870. declare module BABYLON {
  58871. /** @hidden */
  58872. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  58873. private _useDeltaForWorldStep;
  58874. world: any;
  58875. name: string;
  58876. BJSOIMO: any;
  58877. private _raycastResult;
  58878. private _fixedTimeStep;
  58879. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  58880. setGravity(gravity: Vector3): void;
  58881. setTimeStep(timeStep: number): void;
  58882. getTimeStep(): number;
  58883. private _tmpImpostorsArray;
  58884. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58885. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58886. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58887. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58888. private _tmpPositionVector;
  58889. removePhysicsBody(impostor: PhysicsImpostor): void;
  58890. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58891. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58892. isSupported(): boolean;
  58893. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58894. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58895. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58896. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58897. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58898. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58899. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58900. getBodyMass(impostor: PhysicsImpostor): number;
  58901. getBodyFriction(impostor: PhysicsImpostor): number;
  58902. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58903. getBodyRestitution(impostor: PhysicsImpostor): number;
  58904. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58905. sleepBody(impostor: PhysicsImpostor): void;
  58906. wakeUpBody(impostor: PhysicsImpostor): void;
  58907. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58908. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58909. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58910. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58911. getRadius(impostor: PhysicsImpostor): number;
  58912. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58913. dispose(): void;
  58914. /**
  58915. * Does a raycast in the physics world
  58916. * @param from when should the ray start?
  58917. * @param to when should the ray end?
  58918. * @returns PhysicsRaycastResult
  58919. */
  58920. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58921. }
  58922. }
  58923. declare module BABYLON {
  58924. /**
  58925. * Class containing static functions to help procedurally build meshes
  58926. */
  58927. export class RibbonBuilder {
  58928. /**
  58929. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58930. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58931. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58932. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58933. * * 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
  58934. * * 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
  58935. * * 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
  58936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58937. * * 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
  58938. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58939. * * 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
  58940. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58941. * * 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
  58942. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58944. * @param name defines the name of the mesh
  58945. * @param options defines the options used to create the mesh
  58946. * @param scene defines the hosting scene
  58947. * @returns the ribbon mesh
  58948. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58949. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58950. */
  58951. static CreateRibbon(name: string, options: {
  58952. pathArray: Vector3[][];
  58953. closeArray?: boolean;
  58954. closePath?: boolean;
  58955. offset?: number;
  58956. updatable?: boolean;
  58957. sideOrientation?: number;
  58958. frontUVs?: Vector4;
  58959. backUVs?: Vector4;
  58960. instance?: Mesh;
  58961. invertUV?: boolean;
  58962. uvs?: Vector2[];
  58963. colors?: Color4[];
  58964. }, scene?: Nullable<Scene>): Mesh;
  58965. }
  58966. }
  58967. declare module BABYLON {
  58968. /**
  58969. * Class containing static functions to help procedurally build meshes
  58970. */
  58971. export class ShapeBuilder {
  58972. /**
  58973. * 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.
  58974. * * 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.
  58975. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58976. * * 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.
  58977. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58978. * * 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
  58979. * * 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
  58980. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58982. * * 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
  58983. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58985. * @param name defines the name of the mesh
  58986. * @param options defines the options used to create the mesh
  58987. * @param scene defines the hosting scene
  58988. * @returns the extruded shape mesh
  58989. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58990. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58991. */
  58992. static ExtrudeShape(name: string, options: {
  58993. shape: Vector3[];
  58994. path: Vector3[];
  58995. scale?: number;
  58996. rotation?: number;
  58997. cap?: number;
  58998. updatable?: boolean;
  58999. sideOrientation?: number;
  59000. frontUVs?: Vector4;
  59001. backUVs?: Vector4;
  59002. instance?: Mesh;
  59003. invertUV?: boolean;
  59004. }, scene?: Nullable<Scene>): Mesh;
  59005. /**
  59006. * Creates an custom extruded shape mesh.
  59007. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59008. * * 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.
  59009. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59010. * * 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
  59011. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59012. * * 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
  59013. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59014. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59015. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59016. * * 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
  59017. * * 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
  59018. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59020. * * 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
  59021. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59023. * @param name defines the name of the mesh
  59024. * @param options defines the options used to create the mesh
  59025. * @param scene defines the hosting scene
  59026. * @returns the custom extruded shape mesh
  59027. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59028. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59030. */
  59031. static ExtrudeShapeCustom(name: string, options: {
  59032. shape: Vector3[];
  59033. path: Vector3[];
  59034. scaleFunction?: any;
  59035. rotationFunction?: any;
  59036. ribbonCloseArray?: boolean;
  59037. ribbonClosePath?: boolean;
  59038. cap?: number;
  59039. updatable?: boolean;
  59040. sideOrientation?: number;
  59041. frontUVs?: Vector4;
  59042. backUVs?: Vector4;
  59043. instance?: Mesh;
  59044. invertUV?: boolean;
  59045. }, scene?: Nullable<Scene>): Mesh;
  59046. private static _ExtrudeShapeGeneric;
  59047. }
  59048. }
  59049. declare module BABYLON {
  59050. /**
  59051. * AmmoJS Physics plugin
  59052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59053. * @see https://github.com/kripken/ammo.js/
  59054. */
  59055. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59056. private _useDeltaForWorldStep;
  59057. /**
  59058. * Reference to the Ammo library
  59059. */
  59060. bjsAMMO: any;
  59061. /**
  59062. * Created ammoJS world which physics bodies are added to
  59063. */
  59064. world: any;
  59065. /**
  59066. * Name of the plugin
  59067. */
  59068. name: string;
  59069. private _timeStep;
  59070. private _fixedTimeStep;
  59071. private _maxSteps;
  59072. private _tmpQuaternion;
  59073. private _tmpAmmoTransform;
  59074. private _tmpAmmoQuaternion;
  59075. private _tmpAmmoConcreteContactResultCallback;
  59076. private _collisionConfiguration;
  59077. private _dispatcher;
  59078. private _overlappingPairCache;
  59079. private _solver;
  59080. private _softBodySolver;
  59081. private _tmpAmmoVectorA;
  59082. private _tmpAmmoVectorB;
  59083. private _tmpAmmoVectorC;
  59084. private _tmpAmmoVectorD;
  59085. private _tmpContactCallbackResult;
  59086. private _tmpAmmoVectorRCA;
  59087. private _tmpAmmoVectorRCB;
  59088. private _raycastResult;
  59089. private static readonly DISABLE_COLLISION_FLAG;
  59090. private static readonly KINEMATIC_FLAG;
  59091. private static readonly DISABLE_DEACTIVATION_FLAG;
  59092. /**
  59093. * Initializes the ammoJS plugin
  59094. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59095. * @param ammoInjection can be used to inject your own ammo reference
  59096. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59097. */
  59098. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59099. /**
  59100. * Sets the gravity of the physics world (m/(s^2))
  59101. * @param gravity Gravity to set
  59102. */
  59103. setGravity(gravity: Vector3): void;
  59104. /**
  59105. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59106. * @param timeStep timestep to use in seconds
  59107. */
  59108. setTimeStep(timeStep: number): void;
  59109. /**
  59110. * 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)
  59111. * @param fixedTimeStep fixedTimeStep to use in seconds
  59112. */
  59113. setFixedTimeStep(fixedTimeStep: number): void;
  59114. /**
  59115. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59116. * @param maxSteps the maximum number of steps by the physics engine per frame
  59117. */
  59118. setMaxSteps(maxSteps: number): void;
  59119. /**
  59120. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59121. * @returns the current timestep in seconds
  59122. */
  59123. getTimeStep(): number;
  59124. /**
  59125. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59126. */
  59127. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59128. private _isImpostorInContact;
  59129. private _isImpostorPairInContact;
  59130. private _stepSimulation;
  59131. /**
  59132. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59133. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59134. * After the step the babylon meshes are set to the position of the physics imposters
  59135. * @param delta amount of time to step forward
  59136. * @param impostors array of imposters to update before/after the step
  59137. */
  59138. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59139. /**
  59140. * Update babylon mesh to match physics world object
  59141. * @param impostor imposter to match
  59142. */
  59143. private _afterSoftStep;
  59144. /**
  59145. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59146. * @param impostor imposter to match
  59147. */
  59148. private _ropeStep;
  59149. /**
  59150. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59151. * @param impostor imposter to match
  59152. */
  59153. private _softbodyOrClothStep;
  59154. private _tmpMatrix;
  59155. /**
  59156. * Applies an impulse on the imposter
  59157. * @param impostor imposter to apply impulse to
  59158. * @param force amount of force to be applied to the imposter
  59159. * @param contactPoint the location to apply the impulse on the imposter
  59160. */
  59161. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59162. /**
  59163. * Applies a force on the imposter
  59164. * @param impostor imposter to apply force
  59165. * @param force amount of force to be applied to the imposter
  59166. * @param contactPoint the location to apply the force on the imposter
  59167. */
  59168. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59169. /**
  59170. * Creates a physics body using the plugin
  59171. * @param impostor the imposter to create the physics body on
  59172. */
  59173. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59174. /**
  59175. * Removes the physics body from the imposter and disposes of the body's memory
  59176. * @param impostor imposter to remove the physics body from
  59177. */
  59178. removePhysicsBody(impostor: PhysicsImpostor): void;
  59179. /**
  59180. * Generates a joint
  59181. * @param impostorJoint the imposter joint to create the joint with
  59182. */
  59183. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59184. /**
  59185. * Removes a joint
  59186. * @param impostorJoint the imposter joint to remove the joint from
  59187. */
  59188. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59189. private _addMeshVerts;
  59190. /**
  59191. * Initialise the soft body vertices to match its object's (mesh) vertices
  59192. * Softbody vertices (nodes) are in world space and to match this
  59193. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59194. * @param impostor to create the softbody for
  59195. */
  59196. private _softVertexData;
  59197. /**
  59198. * Create an impostor's soft body
  59199. * @param impostor to create the softbody for
  59200. */
  59201. private _createSoftbody;
  59202. /**
  59203. * Create cloth for an impostor
  59204. * @param impostor to create the softbody for
  59205. */
  59206. private _createCloth;
  59207. /**
  59208. * Create rope for an impostor
  59209. * @param impostor to create the softbody for
  59210. */
  59211. private _createRope;
  59212. /**
  59213. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59214. * @param impostor to create the custom physics shape for
  59215. */
  59216. private _createCustom;
  59217. private _addHullVerts;
  59218. private _createShape;
  59219. /**
  59220. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59221. * @param impostor imposter containing the physics body and babylon object
  59222. */
  59223. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59224. /**
  59225. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59226. * @param impostor imposter containing the physics body and babylon object
  59227. * @param newPosition new position
  59228. * @param newRotation new rotation
  59229. */
  59230. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59231. /**
  59232. * If this plugin is supported
  59233. * @returns true if its supported
  59234. */
  59235. isSupported(): boolean;
  59236. /**
  59237. * Sets the linear velocity of the physics body
  59238. * @param impostor imposter to set the velocity on
  59239. * @param velocity velocity to set
  59240. */
  59241. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59242. /**
  59243. * Sets the angular velocity of the physics body
  59244. * @param impostor imposter to set the velocity on
  59245. * @param velocity velocity to set
  59246. */
  59247. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59248. /**
  59249. * gets the linear velocity
  59250. * @param impostor imposter to get linear velocity from
  59251. * @returns linear velocity
  59252. */
  59253. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59254. /**
  59255. * gets the angular velocity
  59256. * @param impostor imposter to get angular velocity from
  59257. * @returns angular velocity
  59258. */
  59259. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59260. /**
  59261. * Sets the mass of physics body
  59262. * @param impostor imposter to set the mass on
  59263. * @param mass mass to set
  59264. */
  59265. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59266. /**
  59267. * Gets the mass of the physics body
  59268. * @param impostor imposter to get the mass from
  59269. * @returns mass
  59270. */
  59271. getBodyMass(impostor: PhysicsImpostor): number;
  59272. /**
  59273. * Gets friction of the impostor
  59274. * @param impostor impostor to get friction from
  59275. * @returns friction value
  59276. */
  59277. getBodyFriction(impostor: PhysicsImpostor): number;
  59278. /**
  59279. * Sets friction of the impostor
  59280. * @param impostor impostor to set friction on
  59281. * @param friction friction value
  59282. */
  59283. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59284. /**
  59285. * Gets restitution of the impostor
  59286. * @param impostor impostor to get restitution from
  59287. * @returns restitution value
  59288. */
  59289. getBodyRestitution(impostor: PhysicsImpostor): number;
  59290. /**
  59291. * Sets resitution of the impostor
  59292. * @param impostor impostor to set resitution on
  59293. * @param restitution resitution value
  59294. */
  59295. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59296. /**
  59297. * Gets pressure inside the impostor
  59298. * @param impostor impostor to get pressure from
  59299. * @returns pressure value
  59300. */
  59301. getBodyPressure(impostor: PhysicsImpostor): number;
  59302. /**
  59303. * Sets pressure inside a soft body impostor
  59304. * Cloth and rope must remain 0 pressure
  59305. * @param impostor impostor to set pressure on
  59306. * @param pressure pressure value
  59307. */
  59308. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59309. /**
  59310. * Gets stiffness of the impostor
  59311. * @param impostor impostor to get stiffness from
  59312. * @returns pressure value
  59313. */
  59314. getBodyStiffness(impostor: PhysicsImpostor): number;
  59315. /**
  59316. * Sets stiffness of the impostor
  59317. * @param impostor impostor to set stiffness on
  59318. * @param stiffness stiffness value from 0 to 1
  59319. */
  59320. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59321. /**
  59322. * Gets velocityIterations of the impostor
  59323. * @param impostor impostor to get velocity iterations from
  59324. * @returns velocityIterations value
  59325. */
  59326. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59327. /**
  59328. * Sets velocityIterations of the impostor
  59329. * @param impostor impostor to set velocity iterations on
  59330. * @param velocityIterations velocityIterations value
  59331. */
  59332. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59333. /**
  59334. * Gets positionIterations of the impostor
  59335. * @param impostor impostor to get position iterations from
  59336. * @returns positionIterations value
  59337. */
  59338. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59339. /**
  59340. * Sets positionIterations of the impostor
  59341. * @param impostor impostor to set position on
  59342. * @param positionIterations positionIterations value
  59343. */
  59344. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59345. /**
  59346. * Append an anchor to a cloth object
  59347. * @param impostor is the cloth impostor to add anchor to
  59348. * @param otherImpostor is the rigid impostor to anchor to
  59349. * @param width ratio across width from 0 to 1
  59350. * @param height ratio up height from 0 to 1
  59351. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59352. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59353. */
  59354. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59355. /**
  59356. * Append an hook to a rope object
  59357. * @param impostor is the rope impostor to add hook to
  59358. * @param otherImpostor is the rigid impostor to hook to
  59359. * @param length ratio along the rope from 0 to 1
  59360. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59361. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59362. */
  59363. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59364. /**
  59365. * Sleeps the physics body and stops it from being active
  59366. * @param impostor impostor to sleep
  59367. */
  59368. sleepBody(impostor: PhysicsImpostor): void;
  59369. /**
  59370. * Activates the physics body
  59371. * @param impostor impostor to activate
  59372. */
  59373. wakeUpBody(impostor: PhysicsImpostor): void;
  59374. /**
  59375. * Updates the distance parameters of the joint
  59376. * @param joint joint to update
  59377. * @param maxDistance maximum distance of the joint
  59378. * @param minDistance minimum distance of the joint
  59379. */
  59380. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59381. /**
  59382. * Sets a motor on the joint
  59383. * @param joint joint to set motor on
  59384. * @param speed speed of the motor
  59385. * @param maxForce maximum force of the motor
  59386. * @param motorIndex index of the motor
  59387. */
  59388. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59389. /**
  59390. * Sets the motors limit
  59391. * @param joint joint to set limit on
  59392. * @param upperLimit upper limit
  59393. * @param lowerLimit lower limit
  59394. */
  59395. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59396. /**
  59397. * Syncs the position and rotation of a mesh with the impostor
  59398. * @param mesh mesh to sync
  59399. * @param impostor impostor to update the mesh with
  59400. */
  59401. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59402. /**
  59403. * Gets the radius of the impostor
  59404. * @param impostor impostor to get radius from
  59405. * @returns the radius
  59406. */
  59407. getRadius(impostor: PhysicsImpostor): number;
  59408. /**
  59409. * Gets the box size of the impostor
  59410. * @param impostor impostor to get box size from
  59411. * @param result the resulting box size
  59412. */
  59413. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59414. /**
  59415. * Disposes of the impostor
  59416. */
  59417. dispose(): void;
  59418. /**
  59419. * Does a raycast in the physics world
  59420. * @param from when should the ray start?
  59421. * @param to when should the ray end?
  59422. * @returns PhysicsRaycastResult
  59423. */
  59424. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59425. }
  59426. }
  59427. declare module BABYLON {
  59428. interface AbstractScene {
  59429. /**
  59430. * The list of reflection probes added to the scene
  59431. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59432. */
  59433. reflectionProbes: Array<ReflectionProbe>;
  59434. /**
  59435. * Removes the given reflection probe from this scene.
  59436. * @param toRemove The reflection probe to remove
  59437. * @returns The index of the removed reflection probe
  59438. */
  59439. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59440. /**
  59441. * Adds the given reflection probe to this scene.
  59442. * @param newReflectionProbe The reflection probe to add
  59443. */
  59444. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59445. }
  59446. /**
  59447. * Class used to generate realtime reflection / refraction cube textures
  59448. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59449. */
  59450. export class ReflectionProbe {
  59451. /** defines the name of the probe */
  59452. name: string;
  59453. private _scene;
  59454. private _renderTargetTexture;
  59455. private _projectionMatrix;
  59456. private _viewMatrix;
  59457. private _target;
  59458. private _add;
  59459. private _attachedMesh;
  59460. private _invertYAxis;
  59461. /** Gets or sets probe position (center of the cube map) */
  59462. position: Vector3;
  59463. /**
  59464. * Creates a new reflection probe
  59465. * @param name defines the name of the probe
  59466. * @param size defines the texture resolution (for each face)
  59467. * @param scene defines the hosting scene
  59468. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59469. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59470. */
  59471. constructor(
  59472. /** defines the name of the probe */
  59473. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59474. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59475. get samples(): number;
  59476. set samples(value: number);
  59477. /** Gets or sets the refresh rate to use (on every frame by default) */
  59478. get refreshRate(): number;
  59479. set refreshRate(value: number);
  59480. /**
  59481. * Gets the hosting scene
  59482. * @returns a Scene
  59483. */
  59484. getScene(): Scene;
  59485. /** Gets the internal CubeTexture used to render to */
  59486. get cubeTexture(): RenderTargetTexture;
  59487. /** Gets the list of meshes to render */
  59488. get renderList(): Nullable<AbstractMesh[]>;
  59489. /**
  59490. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59491. * @param mesh defines the mesh to attach to
  59492. */
  59493. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59494. /**
  59495. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59496. * @param renderingGroupId The rendering group id corresponding to its index
  59497. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59498. */
  59499. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59500. /**
  59501. * Clean all associated resources
  59502. */
  59503. dispose(): void;
  59504. /**
  59505. * Converts the reflection probe information to a readable string for debug purpose.
  59506. * @param fullDetails Supports for multiple levels of logging within scene loading
  59507. * @returns the human readable reflection probe info
  59508. */
  59509. toString(fullDetails?: boolean): string;
  59510. /**
  59511. * Get the class name of the relfection probe.
  59512. * @returns "ReflectionProbe"
  59513. */
  59514. getClassName(): string;
  59515. /**
  59516. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59517. * @returns The JSON representation of the texture
  59518. */
  59519. serialize(): any;
  59520. /**
  59521. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59522. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59523. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59524. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59525. * @returns The parsed reflection probe if successful
  59526. */
  59527. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59528. }
  59529. }
  59530. declare module BABYLON {
  59531. /** @hidden */
  59532. export var _BabylonLoaderRegistered: boolean;
  59533. /**
  59534. * Helps setting up some configuration for the babylon file loader.
  59535. */
  59536. export class BabylonFileLoaderConfiguration {
  59537. /**
  59538. * The loader does not allow injecting custom physix engine into the plugins.
  59539. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59540. * So you could set this variable to your engine import to make it work.
  59541. */
  59542. static LoaderInjectedPhysicsEngine: any;
  59543. }
  59544. }
  59545. declare module BABYLON {
  59546. /**
  59547. * The Physically based simple base material of BJS.
  59548. *
  59549. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59550. * It is used as the base class for both the specGloss and metalRough conventions.
  59551. */
  59552. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59553. /**
  59554. * Number of Simultaneous lights allowed on the material.
  59555. */
  59556. maxSimultaneousLights: number;
  59557. /**
  59558. * If sets to true, disables all the lights affecting the material.
  59559. */
  59560. disableLighting: boolean;
  59561. /**
  59562. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59563. */
  59564. environmentTexture: BaseTexture;
  59565. /**
  59566. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59567. */
  59568. invertNormalMapX: boolean;
  59569. /**
  59570. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59571. */
  59572. invertNormalMapY: boolean;
  59573. /**
  59574. * Normal map used in the model.
  59575. */
  59576. normalTexture: BaseTexture;
  59577. /**
  59578. * Emissivie color used to self-illuminate the model.
  59579. */
  59580. emissiveColor: Color3;
  59581. /**
  59582. * Emissivie texture used to self-illuminate the model.
  59583. */
  59584. emissiveTexture: BaseTexture;
  59585. /**
  59586. * Occlusion Channel Strenght.
  59587. */
  59588. occlusionStrength: number;
  59589. /**
  59590. * Occlusion Texture of the material (adding extra occlusion effects).
  59591. */
  59592. occlusionTexture: BaseTexture;
  59593. /**
  59594. * Defines the alpha limits in alpha test mode.
  59595. */
  59596. alphaCutOff: number;
  59597. /**
  59598. * Gets the current double sided mode.
  59599. */
  59600. get doubleSided(): boolean;
  59601. /**
  59602. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59603. */
  59604. set doubleSided(value: boolean);
  59605. /**
  59606. * Stores the pre-calculated light information of a mesh in a texture.
  59607. */
  59608. lightmapTexture: BaseTexture;
  59609. /**
  59610. * If true, the light map contains occlusion information instead of lighting info.
  59611. */
  59612. useLightmapAsShadowmap: boolean;
  59613. /**
  59614. * Instantiates a new PBRMaterial instance.
  59615. *
  59616. * @param name The material name
  59617. * @param scene The scene the material will be use in.
  59618. */
  59619. constructor(name: string, scene: Scene);
  59620. getClassName(): string;
  59621. }
  59622. }
  59623. declare module BABYLON {
  59624. /**
  59625. * The PBR material of BJS following the metal roughness convention.
  59626. *
  59627. * This fits to the PBR convention in the GLTF definition:
  59628. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  59629. */
  59630. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  59631. /**
  59632. * The base color has two different interpretations depending on the value of metalness.
  59633. * When the material is a metal, the base color is the specific measured reflectance value
  59634. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  59635. * of the material.
  59636. */
  59637. baseColor: Color3;
  59638. /**
  59639. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  59640. * well as opacity information in the alpha channel.
  59641. */
  59642. baseTexture: BaseTexture;
  59643. /**
  59644. * Specifies the metallic scalar value of the material.
  59645. * Can also be used to scale the metalness values of the metallic texture.
  59646. */
  59647. metallic: number;
  59648. /**
  59649. * Specifies the roughness scalar value of the material.
  59650. * Can also be used to scale the roughness values of the metallic texture.
  59651. */
  59652. roughness: number;
  59653. /**
  59654. * Texture containing both the metallic value in the B channel and the
  59655. * roughness value in the G channel to keep better precision.
  59656. */
  59657. metallicRoughnessTexture: BaseTexture;
  59658. /**
  59659. * Instantiates a new PBRMetalRoughnessMaterial instance.
  59660. *
  59661. * @param name The material name
  59662. * @param scene The scene the material will be use in.
  59663. */
  59664. constructor(name: string, scene: Scene);
  59665. /**
  59666. * Return the currrent class name of the material.
  59667. */
  59668. getClassName(): string;
  59669. /**
  59670. * Makes a duplicate of the current material.
  59671. * @param name - name to use for the new material.
  59672. */
  59673. clone(name: string): PBRMetallicRoughnessMaterial;
  59674. /**
  59675. * Serialize the material to a parsable JSON object.
  59676. */
  59677. serialize(): any;
  59678. /**
  59679. * Parses a JSON object correponding to the serialize function.
  59680. */
  59681. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  59682. }
  59683. }
  59684. declare module BABYLON {
  59685. /**
  59686. * The PBR material of BJS following the specular glossiness convention.
  59687. *
  59688. * This fits to the PBR convention in the GLTF definition:
  59689. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  59690. */
  59691. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  59692. /**
  59693. * Specifies the diffuse color of the material.
  59694. */
  59695. diffuseColor: Color3;
  59696. /**
  59697. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  59698. * channel.
  59699. */
  59700. diffuseTexture: BaseTexture;
  59701. /**
  59702. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  59703. */
  59704. specularColor: Color3;
  59705. /**
  59706. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  59707. */
  59708. glossiness: number;
  59709. /**
  59710. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  59711. */
  59712. specularGlossinessTexture: BaseTexture;
  59713. /**
  59714. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  59715. *
  59716. * @param name The material name
  59717. * @param scene The scene the material will be use in.
  59718. */
  59719. constructor(name: string, scene: Scene);
  59720. /**
  59721. * Return the currrent class name of the material.
  59722. */
  59723. getClassName(): string;
  59724. /**
  59725. * Makes a duplicate of the current material.
  59726. * @param name - name to use for the new material.
  59727. */
  59728. clone(name: string): PBRSpecularGlossinessMaterial;
  59729. /**
  59730. * Serialize the material to a parsable JSON object.
  59731. */
  59732. serialize(): any;
  59733. /**
  59734. * Parses a JSON object correponding to the serialize function.
  59735. */
  59736. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  59737. }
  59738. }
  59739. declare module BABYLON {
  59740. /**
  59741. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  59742. * It can help converting any input color in a desired output one. This can then be used to create effects
  59743. * from sepia, black and white to sixties or futuristic rendering...
  59744. *
  59745. * The only supported format is currently 3dl.
  59746. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  59747. */
  59748. export class ColorGradingTexture extends BaseTexture {
  59749. /**
  59750. * The texture URL.
  59751. */
  59752. url: string;
  59753. /**
  59754. * Empty line regex stored for GC.
  59755. */
  59756. private static _noneEmptyLineRegex;
  59757. private _textureMatrix;
  59758. private _onLoad;
  59759. /**
  59760. * Instantiates a ColorGradingTexture from the following parameters.
  59761. *
  59762. * @param url The location of the color gradind data (currently only supporting 3dl)
  59763. * @param sceneOrEngine The scene or engine the texture will be used in
  59764. * @param onLoad defines a callback triggered when the texture has been loaded
  59765. */
  59766. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  59767. /**
  59768. * Fires the onload event from the constructor if requested.
  59769. */
  59770. private _triggerOnLoad;
  59771. /**
  59772. * Returns the texture matrix used in most of the material.
  59773. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  59774. */
  59775. getTextureMatrix(): Matrix;
  59776. /**
  59777. * Occurs when the file being loaded is a .3dl LUT file.
  59778. */
  59779. private load3dlTexture;
  59780. /**
  59781. * Starts the loading process of the texture.
  59782. */
  59783. private loadTexture;
  59784. /**
  59785. * Clones the color gradind texture.
  59786. */
  59787. clone(): ColorGradingTexture;
  59788. /**
  59789. * Called during delayed load for textures.
  59790. */
  59791. delayLoad(): void;
  59792. /**
  59793. * Parses a color grading texture serialized by Babylon.
  59794. * @param parsedTexture The texture information being parsedTexture
  59795. * @param scene The scene to load the texture in
  59796. * @param rootUrl The root url of the data assets to load
  59797. * @return A color gradind texture
  59798. */
  59799. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  59800. /**
  59801. * Serializes the LUT texture to json format.
  59802. */
  59803. serialize(): any;
  59804. }
  59805. }
  59806. declare module BABYLON {
  59807. /**
  59808. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  59809. */
  59810. export class EquiRectangularCubeTexture extends BaseTexture {
  59811. /** The six faces of the cube. */
  59812. private static _FacesMapping;
  59813. private _noMipmap;
  59814. private _onLoad;
  59815. private _onError;
  59816. /** The size of the cubemap. */
  59817. private _size;
  59818. /** The buffer of the image. */
  59819. private _buffer;
  59820. /** The width of the input image. */
  59821. private _width;
  59822. /** The height of the input image. */
  59823. private _height;
  59824. /** The URL to the image. */
  59825. url: string;
  59826. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59827. coordinatesMode: number;
  59828. /**
  59829. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59830. * @param url The location of the image
  59831. * @param scene The scene the texture will be used in
  59832. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59833. * @param noMipmap Forces to not generate the mipmap if true
  59834. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59835. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59836. * @param onLoad — defines a callback called when texture is loaded
  59837. * @param onError — defines a callback called if there is an error
  59838. */
  59839. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59840. /**
  59841. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59842. */
  59843. private loadImage;
  59844. /**
  59845. * Convert the image buffer into a cubemap and create a CubeTexture.
  59846. */
  59847. private loadTexture;
  59848. /**
  59849. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59850. * @param buffer The ArrayBuffer that should be converted.
  59851. * @returns The buffer as Float32Array.
  59852. */
  59853. private getFloat32ArrayFromArrayBuffer;
  59854. /**
  59855. * Get the current class name of the texture useful for serialization or dynamic coding.
  59856. * @returns "EquiRectangularCubeTexture"
  59857. */
  59858. getClassName(): string;
  59859. /**
  59860. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59861. * @returns A clone of the current EquiRectangularCubeTexture.
  59862. */
  59863. clone(): EquiRectangularCubeTexture;
  59864. }
  59865. }
  59866. declare module BABYLON {
  59867. /**
  59868. * Defines the options related to the creation of an HtmlElementTexture
  59869. */
  59870. export interface IHtmlElementTextureOptions {
  59871. /**
  59872. * Defines wether mip maps should be created or not.
  59873. */
  59874. generateMipMaps?: boolean;
  59875. /**
  59876. * Defines the sampling mode of the texture.
  59877. */
  59878. samplingMode?: number;
  59879. /**
  59880. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59881. */
  59882. engine: Nullable<ThinEngine>;
  59883. /**
  59884. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59885. */
  59886. scene: Nullable<Scene>;
  59887. }
  59888. /**
  59889. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59890. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59891. * is automatically managed.
  59892. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59893. * in your application.
  59894. *
  59895. * As the update is not automatic, you need to call them manually.
  59896. */
  59897. export class HtmlElementTexture extends BaseTexture {
  59898. /**
  59899. * The texture URL.
  59900. */
  59901. element: HTMLVideoElement | HTMLCanvasElement;
  59902. private static readonly DefaultOptions;
  59903. private _textureMatrix;
  59904. private _isVideo;
  59905. private _generateMipMaps;
  59906. private _samplingMode;
  59907. /**
  59908. * Instantiates a HtmlElementTexture from the following parameters.
  59909. *
  59910. * @param name Defines the name of the texture
  59911. * @param element Defines the video or canvas the texture is filled with
  59912. * @param options Defines the other none mandatory texture creation options
  59913. */
  59914. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59915. private _createInternalTexture;
  59916. /**
  59917. * Returns the texture matrix used in most of the material.
  59918. */
  59919. getTextureMatrix(): Matrix;
  59920. /**
  59921. * Updates the content of the texture.
  59922. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59923. */
  59924. update(invertY?: Nullable<boolean>): void;
  59925. }
  59926. }
  59927. declare module BABYLON {
  59928. /**
  59929. * Based on jsTGALoader - Javascript loader for TGA file
  59930. * By Vincent Thibault
  59931. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59932. */
  59933. export class TGATools {
  59934. private static _TYPE_INDEXED;
  59935. private static _TYPE_RGB;
  59936. private static _TYPE_GREY;
  59937. private static _TYPE_RLE_INDEXED;
  59938. private static _TYPE_RLE_RGB;
  59939. private static _TYPE_RLE_GREY;
  59940. private static _ORIGIN_MASK;
  59941. private static _ORIGIN_SHIFT;
  59942. private static _ORIGIN_BL;
  59943. private static _ORIGIN_BR;
  59944. private static _ORIGIN_UL;
  59945. private static _ORIGIN_UR;
  59946. /**
  59947. * Gets the header of a TGA file
  59948. * @param data defines the TGA data
  59949. * @returns the header
  59950. */
  59951. static GetTGAHeader(data: Uint8Array): any;
  59952. /**
  59953. * Uploads TGA content to a Babylon Texture
  59954. * @hidden
  59955. */
  59956. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59957. /** @hidden */
  59958. 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;
  59959. /** @hidden */
  59960. 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;
  59961. /** @hidden */
  59962. 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;
  59963. /** @hidden */
  59964. 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;
  59965. /** @hidden */
  59966. 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;
  59967. /** @hidden */
  59968. 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;
  59969. }
  59970. }
  59971. declare module BABYLON {
  59972. /**
  59973. * Implementation of the TGA Texture Loader.
  59974. * @hidden
  59975. */
  59976. export class _TGATextureLoader implements IInternalTextureLoader {
  59977. /**
  59978. * Defines wether the loader supports cascade loading the different faces.
  59979. */
  59980. readonly supportCascades: boolean;
  59981. /**
  59982. * This returns if the loader support the current file information.
  59983. * @param extension defines the file extension of the file being loaded
  59984. * @returns true if the loader can load the specified file
  59985. */
  59986. canLoad(extension: string): boolean;
  59987. /**
  59988. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59989. * @param data contains the texture data
  59990. * @param texture defines the BabylonJS internal texture
  59991. * @param createPolynomials will be true if polynomials have been requested
  59992. * @param onLoad defines the callback to trigger once the texture is ready
  59993. * @param onError defines the callback to trigger in case of error
  59994. */
  59995. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59996. /**
  59997. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59998. * @param data contains the texture data
  59999. * @param texture defines the BabylonJS internal texture
  60000. * @param callback defines the method to call once ready to upload
  60001. */
  60002. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60003. }
  60004. }
  60005. declare module BABYLON {
  60006. /**
  60007. * Info about the .basis files
  60008. */
  60009. class BasisFileInfo {
  60010. /**
  60011. * If the file has alpha
  60012. */
  60013. hasAlpha: boolean;
  60014. /**
  60015. * Info about each image of the basis file
  60016. */
  60017. images: Array<{
  60018. levels: Array<{
  60019. width: number;
  60020. height: number;
  60021. transcodedPixels: ArrayBufferView;
  60022. }>;
  60023. }>;
  60024. }
  60025. /**
  60026. * Result of transcoding a basis file
  60027. */
  60028. class TranscodeResult {
  60029. /**
  60030. * Info about the .basis file
  60031. */
  60032. fileInfo: BasisFileInfo;
  60033. /**
  60034. * Format to use when loading the file
  60035. */
  60036. format: number;
  60037. }
  60038. /**
  60039. * Configuration options for the Basis transcoder
  60040. */
  60041. export class BasisTranscodeConfiguration {
  60042. /**
  60043. * Supported compression formats used to determine the supported output format of the transcoder
  60044. */
  60045. supportedCompressionFormats?: {
  60046. /**
  60047. * etc1 compression format
  60048. */
  60049. etc1?: boolean;
  60050. /**
  60051. * s3tc compression format
  60052. */
  60053. s3tc?: boolean;
  60054. /**
  60055. * pvrtc compression format
  60056. */
  60057. pvrtc?: boolean;
  60058. /**
  60059. * etc2 compression format
  60060. */
  60061. etc2?: boolean;
  60062. };
  60063. /**
  60064. * If mipmap levels should be loaded for transcoded images (Default: true)
  60065. */
  60066. loadMipmapLevels?: boolean;
  60067. /**
  60068. * Index of a single image to load (Default: all images)
  60069. */
  60070. loadSingleImage?: number;
  60071. }
  60072. /**
  60073. * Used to load .Basis files
  60074. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60075. */
  60076. export class BasisTools {
  60077. private static _IgnoreSupportedFormats;
  60078. /**
  60079. * URL to use when loading the basis transcoder
  60080. */
  60081. static JSModuleURL: string;
  60082. /**
  60083. * URL to use when loading the wasm module for the transcoder
  60084. */
  60085. static WasmModuleURL: string;
  60086. /**
  60087. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60088. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60089. * @returns internal format corresponding to the Basis format
  60090. */
  60091. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60092. private static _WorkerPromise;
  60093. private static _Worker;
  60094. private static _actionId;
  60095. private static _CreateWorkerAsync;
  60096. /**
  60097. * Transcodes a loaded image file to compressed pixel data
  60098. * @param data image data to transcode
  60099. * @param config configuration options for the transcoding
  60100. * @returns a promise resulting in the transcoded image
  60101. */
  60102. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60103. /**
  60104. * Loads a texture from the transcode result
  60105. * @param texture texture load to
  60106. * @param transcodeResult the result of transcoding the basis file to load from
  60107. */
  60108. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60109. }
  60110. }
  60111. declare module BABYLON {
  60112. /**
  60113. * Loader for .basis file format
  60114. */
  60115. export class _BasisTextureLoader implements IInternalTextureLoader {
  60116. /**
  60117. * Defines whether the loader supports cascade loading the different faces.
  60118. */
  60119. readonly supportCascades: boolean;
  60120. /**
  60121. * This returns if the loader support the current file information.
  60122. * @param extension defines the file extension of the file being loaded
  60123. * @returns true if the loader can load the specified file
  60124. */
  60125. canLoad(extension: string): boolean;
  60126. /**
  60127. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60128. * @param data contains the texture data
  60129. * @param texture defines the BabylonJS internal texture
  60130. * @param createPolynomials will be true if polynomials have been requested
  60131. * @param onLoad defines the callback to trigger once the texture is ready
  60132. * @param onError defines the callback to trigger in case of error
  60133. */
  60134. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60135. /**
  60136. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60137. * @param data contains the texture data
  60138. * @param texture defines the BabylonJS internal texture
  60139. * @param callback defines the method to call once ready to upload
  60140. */
  60141. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60142. }
  60143. }
  60144. declare module BABYLON {
  60145. /**
  60146. * Defines the basic options interface of a TexturePacker Frame
  60147. */
  60148. export interface ITexturePackerFrame {
  60149. /**
  60150. * The frame ID
  60151. */
  60152. id: number;
  60153. /**
  60154. * The frames Scale
  60155. */
  60156. scale: Vector2;
  60157. /**
  60158. * The Frames offset
  60159. */
  60160. offset: Vector2;
  60161. }
  60162. /**
  60163. * This is a support class for frame Data on texture packer sets.
  60164. */
  60165. export class TexturePackerFrame implements ITexturePackerFrame {
  60166. /**
  60167. * The frame ID
  60168. */
  60169. id: number;
  60170. /**
  60171. * The frames Scale
  60172. */
  60173. scale: Vector2;
  60174. /**
  60175. * The Frames offset
  60176. */
  60177. offset: Vector2;
  60178. /**
  60179. * Initializes a texture package frame.
  60180. * @param id The numerical frame identifier
  60181. * @param scale Scalar Vector2 for UV frame
  60182. * @param offset Vector2 for the frame position in UV units.
  60183. * @returns TexturePackerFrame
  60184. */
  60185. constructor(id: number, scale: Vector2, offset: Vector2);
  60186. }
  60187. }
  60188. declare module BABYLON {
  60189. /**
  60190. * Defines the basic options interface of a TexturePacker
  60191. */
  60192. export interface ITexturePackerOptions {
  60193. /**
  60194. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60195. */
  60196. map?: string[];
  60197. /**
  60198. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60199. */
  60200. uvsIn?: string;
  60201. /**
  60202. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60203. */
  60204. uvsOut?: string;
  60205. /**
  60206. * number representing the layout style. Defaults to LAYOUT_STRIP
  60207. */
  60208. layout?: number;
  60209. /**
  60210. * number of columns if using custom column count layout(2). This defaults to 4.
  60211. */
  60212. colnum?: number;
  60213. /**
  60214. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60215. */
  60216. updateInputMeshes?: boolean;
  60217. /**
  60218. * boolean flag to dispose all the source textures. Defaults to true.
  60219. */
  60220. disposeSources?: boolean;
  60221. /**
  60222. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60223. */
  60224. fillBlanks?: boolean;
  60225. /**
  60226. * string value representing the context fill style color. Defaults to 'black'.
  60227. */
  60228. customFillColor?: string;
  60229. /**
  60230. * Width and Height Value of each Frame in the TexturePacker Sets
  60231. */
  60232. frameSize?: number;
  60233. /**
  60234. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60235. */
  60236. paddingRatio?: number;
  60237. /**
  60238. * Number that declares the fill method for the padding gutter.
  60239. */
  60240. paddingMode?: number;
  60241. /**
  60242. * If in SUBUV_COLOR padding mode what color to use.
  60243. */
  60244. paddingColor?: Color3 | Color4;
  60245. }
  60246. /**
  60247. * Defines the basic interface of a TexturePacker JSON File
  60248. */
  60249. export interface ITexturePackerJSON {
  60250. /**
  60251. * The frame ID
  60252. */
  60253. name: string;
  60254. /**
  60255. * The base64 channel data
  60256. */
  60257. sets: any;
  60258. /**
  60259. * The options of the Packer
  60260. */
  60261. options: ITexturePackerOptions;
  60262. /**
  60263. * The frame data of the Packer
  60264. */
  60265. frames: Array<number>;
  60266. }
  60267. /**
  60268. * This is a support class that generates a series of packed texture sets.
  60269. * @see https://doc.babylonjs.com/babylon101/materials
  60270. */
  60271. export class TexturePacker {
  60272. /** Packer Layout Constant 0 */
  60273. static readonly LAYOUT_STRIP: number;
  60274. /** Packer Layout Constant 1 */
  60275. static readonly LAYOUT_POWER2: number;
  60276. /** Packer Layout Constant 2 */
  60277. static readonly LAYOUT_COLNUM: number;
  60278. /** Packer Layout Constant 0 */
  60279. static readonly SUBUV_WRAP: number;
  60280. /** Packer Layout Constant 1 */
  60281. static readonly SUBUV_EXTEND: number;
  60282. /** Packer Layout Constant 2 */
  60283. static readonly SUBUV_COLOR: number;
  60284. /** The Name of the Texture Package */
  60285. name: string;
  60286. /** The scene scope of the TexturePacker */
  60287. scene: Scene;
  60288. /** The Meshes to target */
  60289. meshes: AbstractMesh[];
  60290. /** Arguments passed with the Constructor */
  60291. options: ITexturePackerOptions;
  60292. /** The promise that is started upon initialization */
  60293. promise: Nullable<Promise<TexturePacker | string>>;
  60294. /** The Container object for the channel sets that are generated */
  60295. sets: object;
  60296. /** The Container array for the frames that are generated */
  60297. frames: TexturePackerFrame[];
  60298. /** The expected number of textures the system is parsing. */
  60299. private _expecting;
  60300. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60301. private _paddingValue;
  60302. /**
  60303. * Initializes a texture package series from an array of meshes or a single mesh.
  60304. * @param name The name of the package
  60305. * @param meshes The target meshes to compose the package from
  60306. * @param options The arguments that texture packer should follow while building.
  60307. * @param scene The scene which the textures are scoped to.
  60308. * @returns TexturePacker
  60309. */
  60310. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60311. /**
  60312. * Starts the package process
  60313. * @param resolve The promises resolution function
  60314. * @returns TexturePacker
  60315. */
  60316. private _createFrames;
  60317. /**
  60318. * Calculates the Size of the Channel Sets
  60319. * @returns Vector2
  60320. */
  60321. private _calculateSize;
  60322. /**
  60323. * Calculates the UV data for the frames.
  60324. * @param baseSize the base frameSize
  60325. * @param padding the base frame padding
  60326. * @param dtSize size of the Dynamic Texture for that channel
  60327. * @param dtUnits is 1/dtSize
  60328. * @param update flag to update the input meshes
  60329. */
  60330. private _calculateMeshUVFrames;
  60331. /**
  60332. * Calculates the frames Offset.
  60333. * @param index of the frame
  60334. * @returns Vector2
  60335. */
  60336. private _getFrameOffset;
  60337. /**
  60338. * Updates a Mesh to the frame data
  60339. * @param mesh that is the target
  60340. * @param frameID or the frame index
  60341. */
  60342. private _updateMeshUV;
  60343. /**
  60344. * Updates a Meshes materials to use the texture packer channels
  60345. * @param m is the mesh to target
  60346. * @param force all channels on the packer to be set.
  60347. */
  60348. private _updateTextureReferences;
  60349. /**
  60350. * Public method to set a Mesh to a frame
  60351. * @param m that is the target
  60352. * @param frameID or the frame index
  60353. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60354. */
  60355. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60356. /**
  60357. * Starts the async promise to compile the texture packer.
  60358. * @returns Promise<void>
  60359. */
  60360. processAsync(): Promise<void>;
  60361. /**
  60362. * Disposes all textures associated with this packer
  60363. */
  60364. dispose(): void;
  60365. /**
  60366. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60367. * @param imageType is the image type to use.
  60368. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60369. */
  60370. download(imageType?: string, quality?: number): void;
  60371. /**
  60372. * Public method to load a texturePacker JSON file.
  60373. * @param data of the JSON file in string format.
  60374. */
  60375. updateFromJSON(data: string): void;
  60376. }
  60377. }
  60378. declare module BABYLON {
  60379. /**
  60380. * 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.
  60381. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60382. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60383. */
  60384. export class CustomProceduralTexture extends ProceduralTexture {
  60385. private _animate;
  60386. private _time;
  60387. private _config;
  60388. private _texturePath;
  60389. /**
  60390. * Instantiates a new Custom Procedural Texture.
  60391. * 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.
  60392. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60393. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60394. * @param name Define the name of the texture
  60395. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60396. * @param size Define the size of the texture to create
  60397. * @param scene Define the scene the texture belongs to
  60398. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60399. * @param generateMipMaps Define if the texture should creates mip maps or not
  60400. */
  60401. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60402. private _loadJson;
  60403. /**
  60404. * Is the texture ready to be used ? (rendered at least once)
  60405. * @returns true if ready, otherwise, false.
  60406. */
  60407. isReady(): boolean;
  60408. /**
  60409. * Render the texture to its associated render target.
  60410. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60411. */
  60412. render(useCameraPostProcess?: boolean): void;
  60413. /**
  60414. * Update the list of dependant textures samplers in the shader.
  60415. */
  60416. updateTextures(): void;
  60417. /**
  60418. * Update the uniform values of the procedural texture in the shader.
  60419. */
  60420. updateShaderUniforms(): void;
  60421. /**
  60422. * Define if the texture animates or not.
  60423. */
  60424. get animate(): boolean;
  60425. set animate(value: boolean);
  60426. }
  60427. }
  60428. declare module BABYLON {
  60429. /** @hidden */
  60430. export var noisePixelShader: {
  60431. name: string;
  60432. shader: string;
  60433. };
  60434. }
  60435. declare module BABYLON {
  60436. /**
  60437. * Class used to generate noise procedural textures
  60438. */
  60439. export class NoiseProceduralTexture extends ProceduralTexture {
  60440. private _time;
  60441. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60442. brightness: number;
  60443. /** Defines the number of octaves to process */
  60444. octaves: number;
  60445. /** Defines the level of persistence (0.8 by default) */
  60446. persistence: number;
  60447. /** Gets or sets animation speed factor (default is 1) */
  60448. animationSpeedFactor: number;
  60449. /**
  60450. * Creates a new NoiseProceduralTexture
  60451. * @param name defines the name fo the texture
  60452. * @param size defines the size of the texture (default is 256)
  60453. * @param scene defines the hosting scene
  60454. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60455. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60456. */
  60457. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60458. private _updateShaderUniforms;
  60459. protected _getDefines(): string;
  60460. /** Generate the current state of the procedural texture */
  60461. render(useCameraPostProcess?: boolean): void;
  60462. /**
  60463. * Serializes this noise procedural texture
  60464. * @returns a serialized noise procedural texture object
  60465. */
  60466. serialize(): any;
  60467. /**
  60468. * Clone the texture.
  60469. * @returns the cloned texture
  60470. */
  60471. clone(): NoiseProceduralTexture;
  60472. /**
  60473. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60474. * @param parsedTexture defines parsed texture data
  60475. * @param scene defines the current scene
  60476. * @param rootUrl defines the root URL containing noise procedural texture information
  60477. * @returns a parsed NoiseProceduralTexture
  60478. */
  60479. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60480. }
  60481. }
  60482. declare module BABYLON {
  60483. /**
  60484. * Raw cube texture where the raw buffers are passed in
  60485. */
  60486. export class RawCubeTexture extends CubeTexture {
  60487. /**
  60488. * Creates a cube texture where the raw buffers are passed in.
  60489. * @param scene defines the scene the texture is attached to
  60490. * @param data defines the array of data to use to create each face
  60491. * @param size defines the size of the textures
  60492. * @param format defines the format of the data
  60493. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60494. * @param generateMipMaps defines if the engine should generate the mip levels
  60495. * @param invertY defines if data must be stored with Y axis inverted
  60496. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60497. * @param compression defines the compression used (null by default)
  60498. */
  60499. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60500. /**
  60501. * Updates the raw cube texture.
  60502. * @param data defines the data to store
  60503. * @param format defines the data format
  60504. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60505. * @param invertY defines if data must be stored with Y axis inverted
  60506. * @param compression defines the compression used (null by default)
  60507. * @param level defines which level of the texture to update
  60508. */
  60509. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60510. /**
  60511. * Updates a raw cube texture with RGBD encoded data.
  60512. * @param data defines the array of data [mipmap][face] to use to create each face
  60513. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60514. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60515. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60516. * @returns a promsie that resolves when the operation is complete
  60517. */
  60518. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60519. /**
  60520. * Clones the raw cube texture.
  60521. * @return a new cube texture
  60522. */
  60523. clone(): CubeTexture;
  60524. /** @hidden */
  60525. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60526. }
  60527. }
  60528. declare module BABYLON {
  60529. /**
  60530. * Class used to store 2D array textures containing user data
  60531. */
  60532. export class RawTexture2DArray extends Texture {
  60533. /** Gets or sets the texture format to use */
  60534. format: number;
  60535. /**
  60536. * Create a new RawTexture2DArray
  60537. * @param data defines the data of the texture
  60538. * @param width defines the width of the texture
  60539. * @param height defines the height of the texture
  60540. * @param depth defines the number of layers of the texture
  60541. * @param format defines the texture format to use
  60542. * @param scene defines the hosting scene
  60543. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60544. * @param invertY defines if texture must be stored with Y axis inverted
  60545. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60546. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60547. */
  60548. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60549. /** Gets or sets the texture format to use */
  60550. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60551. /**
  60552. * Update the texture with new data
  60553. * @param data defines the data to store in the texture
  60554. */
  60555. update(data: ArrayBufferView): void;
  60556. }
  60557. }
  60558. declare module BABYLON {
  60559. /**
  60560. * Class used to store 3D textures containing user data
  60561. */
  60562. export class RawTexture3D extends Texture {
  60563. /** Gets or sets the texture format to use */
  60564. format: number;
  60565. /**
  60566. * Create a new RawTexture3D
  60567. * @param data defines the data of the texture
  60568. * @param width defines the width of the texture
  60569. * @param height defines the height of the texture
  60570. * @param depth defines the depth of the texture
  60571. * @param format defines the texture format to use
  60572. * @param scene defines the hosting scene
  60573. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60574. * @param invertY defines if texture must be stored with Y axis inverted
  60575. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60576. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60577. */
  60578. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60579. /** Gets or sets the texture format to use */
  60580. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60581. /**
  60582. * Update the texture with new data
  60583. * @param data defines the data to store in the texture
  60584. */
  60585. update(data: ArrayBufferView): void;
  60586. }
  60587. }
  60588. declare module BABYLON {
  60589. /**
  60590. * Creates a refraction texture used by refraction channel of the standard material.
  60591. * It is like a mirror but to see through a material.
  60592. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60593. */
  60594. export class RefractionTexture extends RenderTargetTexture {
  60595. /**
  60596. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60597. * 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.
  60598. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60599. */
  60600. refractionPlane: Plane;
  60601. /**
  60602. * Define how deep under the surface we should see.
  60603. */
  60604. depth: number;
  60605. /**
  60606. * Creates a refraction texture used by refraction channel of the standard material.
  60607. * It is like a mirror but to see through a material.
  60608. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60609. * @param name Define the texture name
  60610. * @param size Define the size of the underlying texture
  60611. * @param scene Define the scene the refraction belongs to
  60612. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60613. */
  60614. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  60615. /**
  60616. * Clone the refraction texture.
  60617. * @returns the cloned texture
  60618. */
  60619. clone(): RefractionTexture;
  60620. /**
  60621. * Serialize the texture to a JSON representation you could use in Parse later on
  60622. * @returns the serialized JSON representation
  60623. */
  60624. serialize(): any;
  60625. }
  60626. }
  60627. declare module BABYLON {
  60628. /**
  60629. * Block used to add support for vertex skinning (bones)
  60630. */
  60631. export class BonesBlock extends NodeMaterialBlock {
  60632. /**
  60633. * Creates a new BonesBlock
  60634. * @param name defines the block name
  60635. */
  60636. constructor(name: string);
  60637. /**
  60638. * Initialize the block and prepare the context for build
  60639. * @param state defines the state that will be used for the build
  60640. */
  60641. initialize(state: NodeMaterialBuildState): void;
  60642. /**
  60643. * Gets the current class name
  60644. * @returns the class name
  60645. */
  60646. getClassName(): string;
  60647. /**
  60648. * Gets the matrix indices input component
  60649. */
  60650. get matricesIndices(): NodeMaterialConnectionPoint;
  60651. /**
  60652. * Gets the matrix weights input component
  60653. */
  60654. get matricesWeights(): NodeMaterialConnectionPoint;
  60655. /**
  60656. * Gets the extra matrix indices input component
  60657. */
  60658. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60659. /**
  60660. * Gets the extra matrix weights input component
  60661. */
  60662. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60663. /**
  60664. * Gets the world input component
  60665. */
  60666. get world(): NodeMaterialConnectionPoint;
  60667. /**
  60668. * Gets the output component
  60669. */
  60670. get output(): NodeMaterialConnectionPoint;
  60671. autoConfigure(material: NodeMaterial): void;
  60672. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60673. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60674. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60675. protected _buildBlock(state: NodeMaterialBuildState): this;
  60676. }
  60677. }
  60678. declare module BABYLON {
  60679. /**
  60680. * Block used to add support for instances
  60681. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60682. */
  60683. export class InstancesBlock extends NodeMaterialBlock {
  60684. /**
  60685. * Creates a new InstancesBlock
  60686. * @param name defines the block name
  60687. */
  60688. constructor(name: string);
  60689. /**
  60690. * Gets the current class name
  60691. * @returns the class name
  60692. */
  60693. getClassName(): string;
  60694. /**
  60695. * Gets the first world row input component
  60696. */
  60697. get world0(): NodeMaterialConnectionPoint;
  60698. /**
  60699. * Gets the second world row input component
  60700. */
  60701. get world1(): NodeMaterialConnectionPoint;
  60702. /**
  60703. * Gets the third world row input component
  60704. */
  60705. get world2(): NodeMaterialConnectionPoint;
  60706. /**
  60707. * Gets the forth world row input component
  60708. */
  60709. get world3(): NodeMaterialConnectionPoint;
  60710. /**
  60711. * Gets the world input component
  60712. */
  60713. get world(): NodeMaterialConnectionPoint;
  60714. /**
  60715. * Gets the output component
  60716. */
  60717. get output(): NodeMaterialConnectionPoint;
  60718. /**
  60719. * Gets the isntanceID component
  60720. */
  60721. get instanceID(): NodeMaterialConnectionPoint;
  60722. autoConfigure(material: NodeMaterial): void;
  60723. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  60724. protected _buildBlock(state: NodeMaterialBuildState): this;
  60725. }
  60726. }
  60727. declare module BABYLON {
  60728. /**
  60729. * Block used to add morph targets support to vertex shader
  60730. */
  60731. export class MorphTargetsBlock extends NodeMaterialBlock {
  60732. private _repeatableContentAnchor;
  60733. /**
  60734. * Create a new MorphTargetsBlock
  60735. * @param name defines the block name
  60736. */
  60737. constructor(name: string);
  60738. /**
  60739. * Gets the current class name
  60740. * @returns the class name
  60741. */
  60742. getClassName(): string;
  60743. /**
  60744. * Gets the position input component
  60745. */
  60746. get position(): NodeMaterialConnectionPoint;
  60747. /**
  60748. * Gets the normal input component
  60749. */
  60750. get normal(): NodeMaterialConnectionPoint;
  60751. /**
  60752. * Gets the tangent input component
  60753. */
  60754. get tangent(): NodeMaterialConnectionPoint;
  60755. /**
  60756. * Gets the tangent input component
  60757. */
  60758. get uv(): NodeMaterialConnectionPoint;
  60759. /**
  60760. * Gets the position output component
  60761. */
  60762. get positionOutput(): NodeMaterialConnectionPoint;
  60763. /**
  60764. * Gets the normal output component
  60765. */
  60766. get normalOutput(): NodeMaterialConnectionPoint;
  60767. /**
  60768. * Gets the tangent output component
  60769. */
  60770. get tangentOutput(): NodeMaterialConnectionPoint;
  60771. /**
  60772. * Gets the tangent output component
  60773. */
  60774. get uvOutput(): NodeMaterialConnectionPoint;
  60775. initialize(state: NodeMaterialBuildState): void;
  60776. autoConfigure(material: NodeMaterial): void;
  60777. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60778. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60779. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60780. protected _buildBlock(state: NodeMaterialBuildState): this;
  60781. }
  60782. }
  60783. declare module BABYLON {
  60784. /**
  60785. * Block used to get data information from a light
  60786. */
  60787. export class LightInformationBlock extends NodeMaterialBlock {
  60788. private _lightDataUniformName;
  60789. private _lightColorUniformName;
  60790. private _lightTypeDefineName;
  60791. /**
  60792. * Gets or sets the light associated with this block
  60793. */
  60794. light: Nullable<Light>;
  60795. /**
  60796. * Creates a new LightInformationBlock
  60797. * @param name defines the block name
  60798. */
  60799. constructor(name: string);
  60800. /**
  60801. * Gets the current class name
  60802. * @returns the class name
  60803. */
  60804. getClassName(): string;
  60805. /**
  60806. * Gets the world position input component
  60807. */
  60808. get worldPosition(): NodeMaterialConnectionPoint;
  60809. /**
  60810. * Gets the direction output component
  60811. */
  60812. get direction(): NodeMaterialConnectionPoint;
  60813. /**
  60814. * Gets the direction output component
  60815. */
  60816. get color(): NodeMaterialConnectionPoint;
  60817. /**
  60818. * Gets the direction output component
  60819. */
  60820. get intensity(): NodeMaterialConnectionPoint;
  60821. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60822. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60823. protected _buildBlock(state: NodeMaterialBuildState): this;
  60824. serialize(): any;
  60825. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60826. }
  60827. }
  60828. declare module BABYLON {
  60829. /**
  60830. * Block used to add image processing support to fragment shader
  60831. */
  60832. export class ImageProcessingBlock extends NodeMaterialBlock {
  60833. /**
  60834. * Create a new ImageProcessingBlock
  60835. * @param name defines the block name
  60836. */
  60837. constructor(name: string);
  60838. /**
  60839. * Gets the current class name
  60840. * @returns the class name
  60841. */
  60842. getClassName(): string;
  60843. /**
  60844. * Gets the color input component
  60845. */
  60846. get color(): NodeMaterialConnectionPoint;
  60847. /**
  60848. * Gets the output component
  60849. */
  60850. get output(): NodeMaterialConnectionPoint;
  60851. /**
  60852. * Initialize the block and prepare the context for build
  60853. * @param state defines the state that will be used for the build
  60854. */
  60855. initialize(state: NodeMaterialBuildState): void;
  60856. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60857. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60858. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60859. protected _buildBlock(state: NodeMaterialBuildState): this;
  60860. }
  60861. }
  60862. declare module BABYLON {
  60863. /**
  60864. * Block used to pertub normals based on a normal map
  60865. */
  60866. export class PerturbNormalBlock extends NodeMaterialBlock {
  60867. private _tangentSpaceParameterName;
  60868. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60869. invertX: boolean;
  60870. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60871. invertY: boolean;
  60872. /**
  60873. * Create a new PerturbNormalBlock
  60874. * @param name defines the block name
  60875. */
  60876. constructor(name: string);
  60877. /**
  60878. * Gets the current class name
  60879. * @returns the class name
  60880. */
  60881. getClassName(): string;
  60882. /**
  60883. * Gets the world position input component
  60884. */
  60885. get worldPosition(): NodeMaterialConnectionPoint;
  60886. /**
  60887. * Gets the world normal input component
  60888. */
  60889. get worldNormal(): NodeMaterialConnectionPoint;
  60890. /**
  60891. * Gets the world tangent input component
  60892. */
  60893. get worldTangent(): NodeMaterialConnectionPoint;
  60894. /**
  60895. * Gets the uv input component
  60896. */
  60897. get uv(): NodeMaterialConnectionPoint;
  60898. /**
  60899. * Gets the normal map color input component
  60900. */
  60901. get normalMapColor(): NodeMaterialConnectionPoint;
  60902. /**
  60903. * Gets the strength input component
  60904. */
  60905. get strength(): NodeMaterialConnectionPoint;
  60906. /**
  60907. * Gets the output component
  60908. */
  60909. get output(): NodeMaterialConnectionPoint;
  60910. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60911. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60912. autoConfigure(material: NodeMaterial): void;
  60913. protected _buildBlock(state: NodeMaterialBuildState): this;
  60914. protected _dumpPropertiesCode(): string;
  60915. serialize(): any;
  60916. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60917. }
  60918. }
  60919. declare module BABYLON {
  60920. /**
  60921. * Block used to discard a pixel if a value is smaller than a cutoff
  60922. */
  60923. export class DiscardBlock extends NodeMaterialBlock {
  60924. /**
  60925. * Create a new DiscardBlock
  60926. * @param name defines the block name
  60927. */
  60928. constructor(name: string);
  60929. /**
  60930. * Gets the current class name
  60931. * @returns the class name
  60932. */
  60933. getClassName(): string;
  60934. /**
  60935. * Gets the color input component
  60936. */
  60937. get value(): NodeMaterialConnectionPoint;
  60938. /**
  60939. * Gets the cutoff input component
  60940. */
  60941. get cutoff(): NodeMaterialConnectionPoint;
  60942. protected _buildBlock(state: NodeMaterialBuildState): this;
  60943. }
  60944. }
  60945. declare module BABYLON {
  60946. /**
  60947. * Block used to test if the fragment shader is front facing
  60948. */
  60949. export class FrontFacingBlock extends NodeMaterialBlock {
  60950. /**
  60951. * Creates a new FrontFacingBlock
  60952. * @param name defines the block name
  60953. */
  60954. constructor(name: string);
  60955. /**
  60956. * Gets the current class name
  60957. * @returns the class name
  60958. */
  60959. getClassName(): string;
  60960. /**
  60961. * Gets the output component
  60962. */
  60963. get output(): NodeMaterialConnectionPoint;
  60964. protected _buildBlock(state: NodeMaterialBuildState): this;
  60965. }
  60966. }
  60967. declare module BABYLON {
  60968. /**
  60969. * Block used to get the derivative value on x and y of a given input
  60970. */
  60971. export class DerivativeBlock extends NodeMaterialBlock {
  60972. /**
  60973. * Create a new DerivativeBlock
  60974. * @param name defines the block name
  60975. */
  60976. constructor(name: string);
  60977. /**
  60978. * Gets the current class name
  60979. * @returns the class name
  60980. */
  60981. getClassName(): string;
  60982. /**
  60983. * Gets the input component
  60984. */
  60985. get input(): NodeMaterialConnectionPoint;
  60986. /**
  60987. * Gets the derivative output on x
  60988. */
  60989. get dx(): NodeMaterialConnectionPoint;
  60990. /**
  60991. * Gets the derivative output on y
  60992. */
  60993. get dy(): NodeMaterialConnectionPoint;
  60994. protected _buildBlock(state: NodeMaterialBuildState): this;
  60995. }
  60996. }
  60997. declare module BABYLON {
  60998. /**
  60999. * Block used to add support for scene fog
  61000. */
  61001. export class FogBlock extends NodeMaterialBlock {
  61002. private _fogDistanceName;
  61003. private _fogParameters;
  61004. /**
  61005. * Create a new FogBlock
  61006. * @param name defines the block name
  61007. */
  61008. constructor(name: string);
  61009. /**
  61010. * Gets the current class name
  61011. * @returns the class name
  61012. */
  61013. getClassName(): string;
  61014. /**
  61015. * Gets the world position input component
  61016. */
  61017. get worldPosition(): NodeMaterialConnectionPoint;
  61018. /**
  61019. * Gets the view input component
  61020. */
  61021. get view(): NodeMaterialConnectionPoint;
  61022. /**
  61023. * Gets the color input component
  61024. */
  61025. get input(): NodeMaterialConnectionPoint;
  61026. /**
  61027. * Gets the fog color input component
  61028. */
  61029. get fogColor(): NodeMaterialConnectionPoint;
  61030. /**
  61031. * Gets the output component
  61032. */
  61033. get output(): NodeMaterialConnectionPoint;
  61034. autoConfigure(material: NodeMaterial): void;
  61035. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61036. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61037. protected _buildBlock(state: NodeMaterialBuildState): this;
  61038. }
  61039. }
  61040. declare module BABYLON {
  61041. /**
  61042. * Block used to add light in the fragment shader
  61043. */
  61044. export class LightBlock extends NodeMaterialBlock {
  61045. private _lightId;
  61046. /**
  61047. * Gets or sets the light associated with this block
  61048. */
  61049. light: Nullable<Light>;
  61050. /**
  61051. * Create a new LightBlock
  61052. * @param name defines the block name
  61053. */
  61054. constructor(name: string);
  61055. /**
  61056. * Gets the current class name
  61057. * @returns the class name
  61058. */
  61059. getClassName(): string;
  61060. /**
  61061. * Gets the world position input component
  61062. */
  61063. get worldPosition(): NodeMaterialConnectionPoint;
  61064. /**
  61065. * Gets the world normal input component
  61066. */
  61067. get worldNormal(): NodeMaterialConnectionPoint;
  61068. /**
  61069. * Gets the camera (or eye) position component
  61070. */
  61071. get cameraPosition(): NodeMaterialConnectionPoint;
  61072. /**
  61073. * Gets the glossiness component
  61074. */
  61075. get glossiness(): NodeMaterialConnectionPoint;
  61076. /**
  61077. * Gets the glossinness power component
  61078. */
  61079. get glossPower(): NodeMaterialConnectionPoint;
  61080. /**
  61081. * Gets the diffuse color component
  61082. */
  61083. get diffuseColor(): NodeMaterialConnectionPoint;
  61084. /**
  61085. * Gets the specular color component
  61086. */
  61087. get specularColor(): NodeMaterialConnectionPoint;
  61088. /**
  61089. * Gets the diffuse output component
  61090. */
  61091. get diffuseOutput(): NodeMaterialConnectionPoint;
  61092. /**
  61093. * Gets the specular output component
  61094. */
  61095. get specularOutput(): NodeMaterialConnectionPoint;
  61096. /**
  61097. * Gets the shadow output component
  61098. */
  61099. get shadow(): NodeMaterialConnectionPoint;
  61100. autoConfigure(material: NodeMaterial): void;
  61101. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61102. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61103. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61104. private _injectVertexCode;
  61105. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61106. serialize(): any;
  61107. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61108. }
  61109. }
  61110. declare module BABYLON {
  61111. /**
  61112. * Block used to read a reflection texture from a sampler
  61113. */
  61114. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61115. /**
  61116. * Create a new ReflectionTextureBlock
  61117. * @param name defines the block name
  61118. */
  61119. constructor(name: string);
  61120. /**
  61121. * Gets the current class name
  61122. * @returns the class name
  61123. */
  61124. getClassName(): string;
  61125. /**
  61126. * Gets the world position input component
  61127. */
  61128. get position(): NodeMaterialConnectionPoint;
  61129. /**
  61130. * Gets the world position input component
  61131. */
  61132. get worldPosition(): NodeMaterialConnectionPoint;
  61133. /**
  61134. * Gets the world normal input component
  61135. */
  61136. get worldNormal(): NodeMaterialConnectionPoint;
  61137. /**
  61138. * Gets the world input component
  61139. */
  61140. get world(): NodeMaterialConnectionPoint;
  61141. /**
  61142. * Gets the camera (or eye) position component
  61143. */
  61144. get cameraPosition(): NodeMaterialConnectionPoint;
  61145. /**
  61146. * Gets the view input component
  61147. */
  61148. get view(): NodeMaterialConnectionPoint;
  61149. /**
  61150. * Gets the rgb output component
  61151. */
  61152. get rgb(): NodeMaterialConnectionPoint;
  61153. /**
  61154. * Gets the r output component
  61155. */
  61156. get r(): NodeMaterialConnectionPoint;
  61157. /**
  61158. * Gets the g output component
  61159. */
  61160. get g(): NodeMaterialConnectionPoint;
  61161. /**
  61162. * Gets the b output component
  61163. */
  61164. get b(): NodeMaterialConnectionPoint;
  61165. autoConfigure(material: NodeMaterial): void;
  61166. protected _buildBlock(state: NodeMaterialBuildState): this;
  61167. }
  61168. }
  61169. declare module BABYLON {
  61170. /**
  61171. * Block used to add 2 vectors
  61172. */
  61173. export class AddBlock extends NodeMaterialBlock {
  61174. /**
  61175. * Creates a new AddBlock
  61176. * @param name defines the block name
  61177. */
  61178. constructor(name: string);
  61179. /**
  61180. * Gets the current class name
  61181. * @returns the class name
  61182. */
  61183. getClassName(): string;
  61184. /**
  61185. * Gets the left operand input component
  61186. */
  61187. get left(): NodeMaterialConnectionPoint;
  61188. /**
  61189. * Gets the right operand input component
  61190. */
  61191. get right(): NodeMaterialConnectionPoint;
  61192. /**
  61193. * Gets the output component
  61194. */
  61195. get output(): NodeMaterialConnectionPoint;
  61196. protected _buildBlock(state: NodeMaterialBuildState): this;
  61197. }
  61198. }
  61199. declare module BABYLON {
  61200. /**
  61201. * Block used to scale a vector by a float
  61202. */
  61203. export class ScaleBlock extends NodeMaterialBlock {
  61204. /**
  61205. * Creates a new ScaleBlock
  61206. * @param name defines the block name
  61207. */
  61208. constructor(name: string);
  61209. /**
  61210. * Gets the current class name
  61211. * @returns the class name
  61212. */
  61213. getClassName(): string;
  61214. /**
  61215. * Gets the input component
  61216. */
  61217. get input(): NodeMaterialConnectionPoint;
  61218. /**
  61219. * Gets the factor input component
  61220. */
  61221. get factor(): NodeMaterialConnectionPoint;
  61222. /**
  61223. * Gets the output component
  61224. */
  61225. get output(): NodeMaterialConnectionPoint;
  61226. protected _buildBlock(state: NodeMaterialBuildState): this;
  61227. }
  61228. }
  61229. declare module BABYLON {
  61230. /**
  61231. * Block used to clamp a float
  61232. */
  61233. export class ClampBlock extends NodeMaterialBlock {
  61234. /** Gets or sets the minimum range */
  61235. minimum: number;
  61236. /** Gets or sets the maximum range */
  61237. maximum: number;
  61238. /**
  61239. * Creates a new ClampBlock
  61240. * @param name defines the block name
  61241. */
  61242. constructor(name: string);
  61243. /**
  61244. * Gets the current class name
  61245. * @returns the class name
  61246. */
  61247. getClassName(): string;
  61248. /**
  61249. * Gets the value input component
  61250. */
  61251. get value(): NodeMaterialConnectionPoint;
  61252. /**
  61253. * Gets the output component
  61254. */
  61255. get output(): NodeMaterialConnectionPoint;
  61256. protected _buildBlock(state: NodeMaterialBuildState): this;
  61257. protected _dumpPropertiesCode(): string;
  61258. serialize(): any;
  61259. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61260. }
  61261. }
  61262. declare module BABYLON {
  61263. /**
  61264. * Block used to apply a cross product between 2 vectors
  61265. */
  61266. export class CrossBlock extends NodeMaterialBlock {
  61267. /**
  61268. * Creates a new CrossBlock
  61269. * @param name defines the block name
  61270. */
  61271. constructor(name: string);
  61272. /**
  61273. * Gets the current class name
  61274. * @returns the class name
  61275. */
  61276. getClassName(): string;
  61277. /**
  61278. * Gets the left operand input component
  61279. */
  61280. get left(): NodeMaterialConnectionPoint;
  61281. /**
  61282. * Gets the right operand input component
  61283. */
  61284. get right(): NodeMaterialConnectionPoint;
  61285. /**
  61286. * Gets the output component
  61287. */
  61288. get output(): NodeMaterialConnectionPoint;
  61289. protected _buildBlock(state: NodeMaterialBuildState): this;
  61290. }
  61291. }
  61292. declare module BABYLON {
  61293. /**
  61294. * Block used to apply a dot product between 2 vectors
  61295. */
  61296. export class DotBlock extends NodeMaterialBlock {
  61297. /**
  61298. * Creates a new DotBlock
  61299. * @param name defines the block name
  61300. */
  61301. constructor(name: string);
  61302. /**
  61303. * Gets the current class name
  61304. * @returns the class name
  61305. */
  61306. getClassName(): string;
  61307. /**
  61308. * Gets the left operand input component
  61309. */
  61310. get left(): NodeMaterialConnectionPoint;
  61311. /**
  61312. * Gets the right operand input component
  61313. */
  61314. get right(): NodeMaterialConnectionPoint;
  61315. /**
  61316. * Gets the output component
  61317. */
  61318. get output(): NodeMaterialConnectionPoint;
  61319. protected _buildBlock(state: NodeMaterialBuildState): this;
  61320. }
  61321. }
  61322. declare module BABYLON {
  61323. /**
  61324. * Block used to normalize a vector
  61325. */
  61326. export class NormalizeBlock extends NodeMaterialBlock {
  61327. /**
  61328. * Creates a new NormalizeBlock
  61329. * @param name defines the block name
  61330. */
  61331. constructor(name: string);
  61332. /**
  61333. * Gets the current class name
  61334. * @returns the class name
  61335. */
  61336. getClassName(): string;
  61337. /**
  61338. * Gets the input component
  61339. */
  61340. get input(): NodeMaterialConnectionPoint;
  61341. /**
  61342. * Gets the output component
  61343. */
  61344. get output(): NodeMaterialConnectionPoint;
  61345. protected _buildBlock(state: NodeMaterialBuildState): this;
  61346. }
  61347. }
  61348. declare module BABYLON {
  61349. /**
  61350. * Operations supported by the Trigonometry block
  61351. */
  61352. export enum TrigonometryBlockOperations {
  61353. /** Cos */
  61354. Cos = 0,
  61355. /** Sin */
  61356. Sin = 1,
  61357. /** Abs */
  61358. Abs = 2,
  61359. /** Exp */
  61360. Exp = 3,
  61361. /** Exp2 */
  61362. Exp2 = 4,
  61363. /** Round */
  61364. Round = 5,
  61365. /** Floor */
  61366. Floor = 6,
  61367. /** Ceiling */
  61368. Ceiling = 7,
  61369. /** Square root */
  61370. Sqrt = 8,
  61371. /** Log */
  61372. Log = 9,
  61373. /** Tangent */
  61374. Tan = 10,
  61375. /** Arc tangent */
  61376. ArcTan = 11,
  61377. /** Arc cosinus */
  61378. ArcCos = 12,
  61379. /** Arc sinus */
  61380. ArcSin = 13,
  61381. /** Fraction */
  61382. Fract = 14,
  61383. /** Sign */
  61384. Sign = 15,
  61385. /** To radians (from degrees) */
  61386. Radians = 16,
  61387. /** To degrees (from radians) */
  61388. Degrees = 17
  61389. }
  61390. /**
  61391. * Block used to apply trigonometry operation to floats
  61392. */
  61393. export class TrigonometryBlock extends NodeMaterialBlock {
  61394. /**
  61395. * Gets or sets the operation applied by the block
  61396. */
  61397. operation: TrigonometryBlockOperations;
  61398. /**
  61399. * Creates a new TrigonometryBlock
  61400. * @param name defines the block name
  61401. */
  61402. constructor(name: string);
  61403. /**
  61404. * Gets the current class name
  61405. * @returns the class name
  61406. */
  61407. getClassName(): string;
  61408. /**
  61409. * Gets the input component
  61410. */
  61411. get input(): NodeMaterialConnectionPoint;
  61412. /**
  61413. * Gets the output component
  61414. */
  61415. get output(): NodeMaterialConnectionPoint;
  61416. protected _buildBlock(state: NodeMaterialBuildState): this;
  61417. serialize(): any;
  61418. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61419. protected _dumpPropertiesCode(): string;
  61420. }
  61421. }
  61422. declare module BABYLON {
  61423. /**
  61424. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61425. */
  61426. export class ColorMergerBlock extends NodeMaterialBlock {
  61427. /**
  61428. * Create a new ColorMergerBlock
  61429. * @param name defines the block name
  61430. */
  61431. constructor(name: string);
  61432. /**
  61433. * Gets the current class name
  61434. * @returns the class name
  61435. */
  61436. getClassName(): string;
  61437. /**
  61438. * Gets the rgb component (input)
  61439. */
  61440. get rgbIn(): NodeMaterialConnectionPoint;
  61441. /**
  61442. * Gets the r component (input)
  61443. */
  61444. get r(): NodeMaterialConnectionPoint;
  61445. /**
  61446. * Gets the g component (input)
  61447. */
  61448. get g(): NodeMaterialConnectionPoint;
  61449. /**
  61450. * Gets the b component (input)
  61451. */
  61452. get b(): NodeMaterialConnectionPoint;
  61453. /**
  61454. * Gets the a component (input)
  61455. */
  61456. get a(): NodeMaterialConnectionPoint;
  61457. /**
  61458. * Gets the rgba component (output)
  61459. */
  61460. get rgba(): NodeMaterialConnectionPoint;
  61461. /**
  61462. * Gets the rgb component (output)
  61463. */
  61464. get rgbOut(): NodeMaterialConnectionPoint;
  61465. /**
  61466. * Gets the rgb component (output)
  61467. * @deprecated Please use rgbOut instead.
  61468. */
  61469. get rgb(): NodeMaterialConnectionPoint;
  61470. protected _buildBlock(state: NodeMaterialBuildState): this;
  61471. }
  61472. }
  61473. declare module BABYLON {
  61474. /**
  61475. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61476. */
  61477. export class VectorSplitterBlock extends NodeMaterialBlock {
  61478. /**
  61479. * Create a new VectorSplitterBlock
  61480. * @param name defines the block name
  61481. */
  61482. constructor(name: string);
  61483. /**
  61484. * Gets the current class name
  61485. * @returns the class name
  61486. */
  61487. getClassName(): string;
  61488. /**
  61489. * Gets the xyzw component (input)
  61490. */
  61491. get xyzw(): NodeMaterialConnectionPoint;
  61492. /**
  61493. * Gets the xyz component (input)
  61494. */
  61495. get xyzIn(): NodeMaterialConnectionPoint;
  61496. /**
  61497. * Gets the xy component (input)
  61498. */
  61499. get xyIn(): NodeMaterialConnectionPoint;
  61500. /**
  61501. * Gets the xyz component (output)
  61502. */
  61503. get xyzOut(): NodeMaterialConnectionPoint;
  61504. /**
  61505. * Gets the xy component (output)
  61506. */
  61507. get xyOut(): NodeMaterialConnectionPoint;
  61508. /**
  61509. * Gets the x component (output)
  61510. */
  61511. get x(): NodeMaterialConnectionPoint;
  61512. /**
  61513. * Gets the y component (output)
  61514. */
  61515. get y(): NodeMaterialConnectionPoint;
  61516. /**
  61517. * Gets the z component (output)
  61518. */
  61519. get z(): NodeMaterialConnectionPoint;
  61520. /**
  61521. * Gets the w component (output)
  61522. */
  61523. get w(): NodeMaterialConnectionPoint;
  61524. protected _inputRename(name: string): string;
  61525. protected _outputRename(name: string): string;
  61526. protected _buildBlock(state: NodeMaterialBuildState): this;
  61527. }
  61528. }
  61529. declare module BABYLON {
  61530. /**
  61531. * Block used to lerp between 2 values
  61532. */
  61533. export class LerpBlock extends NodeMaterialBlock {
  61534. /**
  61535. * Creates a new LerpBlock
  61536. * @param name defines the block name
  61537. */
  61538. constructor(name: string);
  61539. /**
  61540. * Gets the current class name
  61541. * @returns the class name
  61542. */
  61543. getClassName(): string;
  61544. /**
  61545. * Gets the left operand input component
  61546. */
  61547. get left(): NodeMaterialConnectionPoint;
  61548. /**
  61549. * Gets the right operand input component
  61550. */
  61551. get right(): NodeMaterialConnectionPoint;
  61552. /**
  61553. * Gets the gradient operand input component
  61554. */
  61555. get gradient(): NodeMaterialConnectionPoint;
  61556. /**
  61557. * Gets the output component
  61558. */
  61559. get output(): NodeMaterialConnectionPoint;
  61560. protected _buildBlock(state: NodeMaterialBuildState): this;
  61561. }
  61562. }
  61563. declare module BABYLON {
  61564. /**
  61565. * Block used to divide 2 vectors
  61566. */
  61567. export class DivideBlock extends NodeMaterialBlock {
  61568. /**
  61569. * Creates a new DivideBlock
  61570. * @param name defines the block name
  61571. */
  61572. constructor(name: string);
  61573. /**
  61574. * Gets the current class name
  61575. * @returns the class name
  61576. */
  61577. getClassName(): string;
  61578. /**
  61579. * Gets the left operand input component
  61580. */
  61581. get left(): NodeMaterialConnectionPoint;
  61582. /**
  61583. * Gets the right operand input component
  61584. */
  61585. get right(): NodeMaterialConnectionPoint;
  61586. /**
  61587. * Gets the output component
  61588. */
  61589. get output(): NodeMaterialConnectionPoint;
  61590. protected _buildBlock(state: NodeMaterialBuildState): this;
  61591. }
  61592. }
  61593. declare module BABYLON {
  61594. /**
  61595. * Block used to subtract 2 vectors
  61596. */
  61597. export class SubtractBlock extends NodeMaterialBlock {
  61598. /**
  61599. * Creates a new SubtractBlock
  61600. * @param name defines the block name
  61601. */
  61602. constructor(name: string);
  61603. /**
  61604. * Gets the current class name
  61605. * @returns the class name
  61606. */
  61607. getClassName(): string;
  61608. /**
  61609. * Gets the left operand input component
  61610. */
  61611. get left(): NodeMaterialConnectionPoint;
  61612. /**
  61613. * Gets the right operand input component
  61614. */
  61615. get right(): NodeMaterialConnectionPoint;
  61616. /**
  61617. * Gets the output component
  61618. */
  61619. get output(): NodeMaterialConnectionPoint;
  61620. protected _buildBlock(state: NodeMaterialBuildState): this;
  61621. }
  61622. }
  61623. declare module BABYLON {
  61624. /**
  61625. * Block used to step a value
  61626. */
  61627. export class StepBlock extends NodeMaterialBlock {
  61628. /**
  61629. * Creates a new StepBlock
  61630. * @param name defines the block name
  61631. */
  61632. constructor(name: string);
  61633. /**
  61634. * Gets the current class name
  61635. * @returns the class name
  61636. */
  61637. getClassName(): string;
  61638. /**
  61639. * Gets the value operand input component
  61640. */
  61641. get value(): NodeMaterialConnectionPoint;
  61642. /**
  61643. * Gets the edge operand input component
  61644. */
  61645. get edge(): NodeMaterialConnectionPoint;
  61646. /**
  61647. * Gets the output component
  61648. */
  61649. get output(): NodeMaterialConnectionPoint;
  61650. protected _buildBlock(state: NodeMaterialBuildState): this;
  61651. }
  61652. }
  61653. declare module BABYLON {
  61654. /**
  61655. * Block used to get the opposite (1 - x) of a value
  61656. */
  61657. export class OneMinusBlock extends NodeMaterialBlock {
  61658. /**
  61659. * Creates a new OneMinusBlock
  61660. * @param name defines the block name
  61661. */
  61662. constructor(name: string);
  61663. /**
  61664. * Gets the current class name
  61665. * @returns the class name
  61666. */
  61667. getClassName(): string;
  61668. /**
  61669. * Gets the input component
  61670. */
  61671. get input(): NodeMaterialConnectionPoint;
  61672. /**
  61673. * Gets the output component
  61674. */
  61675. get output(): NodeMaterialConnectionPoint;
  61676. protected _buildBlock(state: NodeMaterialBuildState): this;
  61677. }
  61678. }
  61679. declare module BABYLON {
  61680. /**
  61681. * Block used to get the view direction
  61682. */
  61683. export class ViewDirectionBlock extends NodeMaterialBlock {
  61684. /**
  61685. * Creates a new ViewDirectionBlock
  61686. * @param name defines the block name
  61687. */
  61688. constructor(name: string);
  61689. /**
  61690. * Gets the current class name
  61691. * @returns the class name
  61692. */
  61693. getClassName(): string;
  61694. /**
  61695. * Gets the world position component
  61696. */
  61697. get worldPosition(): NodeMaterialConnectionPoint;
  61698. /**
  61699. * Gets the camera position component
  61700. */
  61701. get cameraPosition(): NodeMaterialConnectionPoint;
  61702. /**
  61703. * Gets the output component
  61704. */
  61705. get output(): NodeMaterialConnectionPoint;
  61706. autoConfigure(material: NodeMaterial): void;
  61707. protected _buildBlock(state: NodeMaterialBuildState): this;
  61708. }
  61709. }
  61710. declare module BABYLON {
  61711. /**
  61712. * Block used to compute fresnel value
  61713. */
  61714. export class FresnelBlock extends NodeMaterialBlock {
  61715. /**
  61716. * Create a new FresnelBlock
  61717. * @param name defines the block name
  61718. */
  61719. constructor(name: string);
  61720. /**
  61721. * Gets the current class name
  61722. * @returns the class name
  61723. */
  61724. getClassName(): string;
  61725. /**
  61726. * Gets the world normal input component
  61727. */
  61728. get worldNormal(): NodeMaterialConnectionPoint;
  61729. /**
  61730. * Gets the view direction input component
  61731. */
  61732. get viewDirection(): NodeMaterialConnectionPoint;
  61733. /**
  61734. * Gets the bias input component
  61735. */
  61736. get bias(): NodeMaterialConnectionPoint;
  61737. /**
  61738. * Gets the camera (or eye) position component
  61739. */
  61740. get power(): NodeMaterialConnectionPoint;
  61741. /**
  61742. * Gets the fresnel output component
  61743. */
  61744. get fresnel(): NodeMaterialConnectionPoint;
  61745. autoConfigure(material: NodeMaterial): void;
  61746. protected _buildBlock(state: NodeMaterialBuildState): this;
  61747. }
  61748. }
  61749. declare module BABYLON {
  61750. /**
  61751. * Block used to get the max of 2 values
  61752. */
  61753. export class MaxBlock extends NodeMaterialBlock {
  61754. /**
  61755. * Creates a new MaxBlock
  61756. * @param name defines the block name
  61757. */
  61758. constructor(name: string);
  61759. /**
  61760. * Gets the current class name
  61761. * @returns the class name
  61762. */
  61763. getClassName(): string;
  61764. /**
  61765. * Gets the left operand input component
  61766. */
  61767. get left(): NodeMaterialConnectionPoint;
  61768. /**
  61769. * Gets the right operand input component
  61770. */
  61771. get right(): NodeMaterialConnectionPoint;
  61772. /**
  61773. * Gets the output component
  61774. */
  61775. get output(): NodeMaterialConnectionPoint;
  61776. protected _buildBlock(state: NodeMaterialBuildState): this;
  61777. }
  61778. }
  61779. declare module BABYLON {
  61780. /**
  61781. * Block used to get the min of 2 values
  61782. */
  61783. export class MinBlock extends NodeMaterialBlock {
  61784. /**
  61785. * Creates a new MinBlock
  61786. * @param name defines the block name
  61787. */
  61788. constructor(name: string);
  61789. /**
  61790. * Gets the current class name
  61791. * @returns the class name
  61792. */
  61793. getClassName(): string;
  61794. /**
  61795. * Gets the left operand input component
  61796. */
  61797. get left(): NodeMaterialConnectionPoint;
  61798. /**
  61799. * Gets the right operand input component
  61800. */
  61801. get right(): NodeMaterialConnectionPoint;
  61802. /**
  61803. * Gets the output component
  61804. */
  61805. get output(): NodeMaterialConnectionPoint;
  61806. protected _buildBlock(state: NodeMaterialBuildState): this;
  61807. }
  61808. }
  61809. declare module BABYLON {
  61810. /**
  61811. * Block used to get the distance between 2 values
  61812. */
  61813. export class DistanceBlock extends NodeMaterialBlock {
  61814. /**
  61815. * Creates a new DistanceBlock
  61816. * @param name defines the block name
  61817. */
  61818. constructor(name: string);
  61819. /**
  61820. * Gets the current class name
  61821. * @returns the class name
  61822. */
  61823. getClassName(): string;
  61824. /**
  61825. * Gets the left operand input component
  61826. */
  61827. get left(): NodeMaterialConnectionPoint;
  61828. /**
  61829. * Gets the right operand input component
  61830. */
  61831. get right(): NodeMaterialConnectionPoint;
  61832. /**
  61833. * Gets the output component
  61834. */
  61835. get output(): NodeMaterialConnectionPoint;
  61836. protected _buildBlock(state: NodeMaterialBuildState): this;
  61837. }
  61838. }
  61839. declare module BABYLON {
  61840. /**
  61841. * Block used to get the length of a vector
  61842. */
  61843. export class LengthBlock extends NodeMaterialBlock {
  61844. /**
  61845. * Creates a new LengthBlock
  61846. * @param name defines the block name
  61847. */
  61848. constructor(name: string);
  61849. /**
  61850. * Gets the current class name
  61851. * @returns the class name
  61852. */
  61853. getClassName(): string;
  61854. /**
  61855. * Gets the value input component
  61856. */
  61857. get value(): NodeMaterialConnectionPoint;
  61858. /**
  61859. * Gets the output component
  61860. */
  61861. get output(): NodeMaterialConnectionPoint;
  61862. protected _buildBlock(state: NodeMaterialBuildState): this;
  61863. }
  61864. }
  61865. declare module BABYLON {
  61866. /**
  61867. * Block used to get negative version of a value (i.e. x * -1)
  61868. */
  61869. export class NegateBlock extends NodeMaterialBlock {
  61870. /**
  61871. * Creates a new NegateBlock
  61872. * @param name defines the block name
  61873. */
  61874. constructor(name: string);
  61875. /**
  61876. * Gets the current class name
  61877. * @returns the class name
  61878. */
  61879. getClassName(): string;
  61880. /**
  61881. * Gets the value input component
  61882. */
  61883. get value(): NodeMaterialConnectionPoint;
  61884. /**
  61885. * Gets the output component
  61886. */
  61887. get output(): NodeMaterialConnectionPoint;
  61888. protected _buildBlock(state: NodeMaterialBuildState): this;
  61889. }
  61890. }
  61891. declare module BABYLON {
  61892. /**
  61893. * Block used to get the value of the first parameter raised to the power of the second
  61894. */
  61895. export class PowBlock extends NodeMaterialBlock {
  61896. /**
  61897. * Creates a new PowBlock
  61898. * @param name defines the block name
  61899. */
  61900. constructor(name: string);
  61901. /**
  61902. * Gets the current class name
  61903. * @returns the class name
  61904. */
  61905. getClassName(): string;
  61906. /**
  61907. * Gets the value operand input component
  61908. */
  61909. get value(): NodeMaterialConnectionPoint;
  61910. /**
  61911. * Gets the power operand input component
  61912. */
  61913. get power(): NodeMaterialConnectionPoint;
  61914. /**
  61915. * Gets the output component
  61916. */
  61917. get output(): NodeMaterialConnectionPoint;
  61918. protected _buildBlock(state: NodeMaterialBuildState): this;
  61919. }
  61920. }
  61921. declare module BABYLON {
  61922. /**
  61923. * Block used to get a random number
  61924. */
  61925. export class RandomNumberBlock extends NodeMaterialBlock {
  61926. /**
  61927. * Creates a new RandomNumberBlock
  61928. * @param name defines the block name
  61929. */
  61930. constructor(name: string);
  61931. /**
  61932. * Gets the current class name
  61933. * @returns the class name
  61934. */
  61935. getClassName(): string;
  61936. /**
  61937. * Gets the seed input component
  61938. */
  61939. get seed(): NodeMaterialConnectionPoint;
  61940. /**
  61941. * Gets the output component
  61942. */
  61943. get output(): NodeMaterialConnectionPoint;
  61944. protected _buildBlock(state: NodeMaterialBuildState): this;
  61945. }
  61946. }
  61947. declare module BABYLON {
  61948. /**
  61949. * Block used to compute arc tangent of 2 values
  61950. */
  61951. export class ArcTan2Block extends NodeMaterialBlock {
  61952. /**
  61953. * Creates a new ArcTan2Block
  61954. * @param name defines the block name
  61955. */
  61956. constructor(name: string);
  61957. /**
  61958. * Gets the current class name
  61959. * @returns the class name
  61960. */
  61961. getClassName(): string;
  61962. /**
  61963. * Gets the x operand input component
  61964. */
  61965. get x(): NodeMaterialConnectionPoint;
  61966. /**
  61967. * Gets the y operand input component
  61968. */
  61969. get y(): NodeMaterialConnectionPoint;
  61970. /**
  61971. * Gets the output component
  61972. */
  61973. get output(): NodeMaterialConnectionPoint;
  61974. protected _buildBlock(state: NodeMaterialBuildState): this;
  61975. }
  61976. }
  61977. declare module BABYLON {
  61978. /**
  61979. * Block used to smooth step a value
  61980. */
  61981. export class SmoothStepBlock extends NodeMaterialBlock {
  61982. /**
  61983. * Creates a new SmoothStepBlock
  61984. * @param name defines the block name
  61985. */
  61986. constructor(name: string);
  61987. /**
  61988. * Gets the current class name
  61989. * @returns the class name
  61990. */
  61991. getClassName(): string;
  61992. /**
  61993. * Gets the value operand input component
  61994. */
  61995. get value(): NodeMaterialConnectionPoint;
  61996. /**
  61997. * Gets the first edge operand input component
  61998. */
  61999. get edge0(): NodeMaterialConnectionPoint;
  62000. /**
  62001. * Gets the second edge operand input component
  62002. */
  62003. get edge1(): NodeMaterialConnectionPoint;
  62004. /**
  62005. * Gets the output component
  62006. */
  62007. get output(): NodeMaterialConnectionPoint;
  62008. protected _buildBlock(state: NodeMaterialBuildState): this;
  62009. }
  62010. }
  62011. declare module BABYLON {
  62012. /**
  62013. * Block used to get the reciprocal (1 / x) of a value
  62014. */
  62015. export class ReciprocalBlock extends NodeMaterialBlock {
  62016. /**
  62017. * Creates a new ReciprocalBlock
  62018. * @param name defines the block name
  62019. */
  62020. constructor(name: string);
  62021. /**
  62022. * Gets the current class name
  62023. * @returns the class name
  62024. */
  62025. getClassName(): string;
  62026. /**
  62027. * Gets the input component
  62028. */
  62029. get input(): NodeMaterialConnectionPoint;
  62030. /**
  62031. * Gets the output component
  62032. */
  62033. get output(): NodeMaterialConnectionPoint;
  62034. protected _buildBlock(state: NodeMaterialBuildState): this;
  62035. }
  62036. }
  62037. declare module BABYLON {
  62038. /**
  62039. * Block used to replace a color by another one
  62040. */
  62041. export class ReplaceColorBlock extends NodeMaterialBlock {
  62042. /**
  62043. * Creates a new ReplaceColorBlock
  62044. * @param name defines the block name
  62045. */
  62046. constructor(name: string);
  62047. /**
  62048. * Gets the current class name
  62049. * @returns the class name
  62050. */
  62051. getClassName(): string;
  62052. /**
  62053. * Gets the value input component
  62054. */
  62055. get value(): NodeMaterialConnectionPoint;
  62056. /**
  62057. * Gets the reference input component
  62058. */
  62059. get reference(): NodeMaterialConnectionPoint;
  62060. /**
  62061. * Gets the distance input component
  62062. */
  62063. get distance(): NodeMaterialConnectionPoint;
  62064. /**
  62065. * Gets the replacement input component
  62066. */
  62067. get replacement(): NodeMaterialConnectionPoint;
  62068. /**
  62069. * Gets the output component
  62070. */
  62071. get output(): NodeMaterialConnectionPoint;
  62072. protected _buildBlock(state: NodeMaterialBuildState): this;
  62073. }
  62074. }
  62075. declare module BABYLON {
  62076. /**
  62077. * Block used to posterize a value
  62078. * @see https://en.wikipedia.org/wiki/Posterization
  62079. */
  62080. export class PosterizeBlock extends NodeMaterialBlock {
  62081. /**
  62082. * Creates a new PosterizeBlock
  62083. * @param name defines the block name
  62084. */
  62085. constructor(name: string);
  62086. /**
  62087. * Gets the current class name
  62088. * @returns the class name
  62089. */
  62090. getClassName(): string;
  62091. /**
  62092. * Gets the value input component
  62093. */
  62094. get value(): NodeMaterialConnectionPoint;
  62095. /**
  62096. * Gets the steps input component
  62097. */
  62098. get steps(): NodeMaterialConnectionPoint;
  62099. /**
  62100. * Gets the output component
  62101. */
  62102. get output(): NodeMaterialConnectionPoint;
  62103. protected _buildBlock(state: NodeMaterialBuildState): this;
  62104. }
  62105. }
  62106. declare module BABYLON {
  62107. /**
  62108. * Operations supported by the Wave block
  62109. */
  62110. export enum WaveBlockKind {
  62111. /** SawTooth */
  62112. SawTooth = 0,
  62113. /** Square */
  62114. Square = 1,
  62115. /** Triangle */
  62116. Triangle = 2
  62117. }
  62118. /**
  62119. * Block used to apply wave operation to floats
  62120. */
  62121. export class WaveBlock extends NodeMaterialBlock {
  62122. /**
  62123. * Gets or sets the kibnd of wave to be applied by the block
  62124. */
  62125. kind: WaveBlockKind;
  62126. /**
  62127. * Creates a new WaveBlock
  62128. * @param name defines the block name
  62129. */
  62130. constructor(name: string);
  62131. /**
  62132. * Gets the current class name
  62133. * @returns the class name
  62134. */
  62135. getClassName(): string;
  62136. /**
  62137. * Gets the input component
  62138. */
  62139. get input(): NodeMaterialConnectionPoint;
  62140. /**
  62141. * Gets the output component
  62142. */
  62143. get output(): NodeMaterialConnectionPoint;
  62144. protected _buildBlock(state: NodeMaterialBuildState): this;
  62145. serialize(): any;
  62146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62147. }
  62148. }
  62149. declare module BABYLON {
  62150. /**
  62151. * Class used to store a color step for the GradientBlock
  62152. */
  62153. export class GradientBlockColorStep {
  62154. /**
  62155. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62156. */
  62157. step: number;
  62158. /**
  62159. * Gets or sets the color associated with this step
  62160. */
  62161. color: Color3;
  62162. /**
  62163. * Creates a new GradientBlockColorStep
  62164. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62165. * @param color defines the color associated with this step
  62166. */
  62167. constructor(
  62168. /**
  62169. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62170. */
  62171. step: number,
  62172. /**
  62173. * Gets or sets the color associated with this step
  62174. */
  62175. color: Color3);
  62176. }
  62177. /**
  62178. * Block used to return a color from a gradient based on an input value between 0 and 1
  62179. */
  62180. export class GradientBlock extends NodeMaterialBlock {
  62181. /**
  62182. * Gets or sets the list of color steps
  62183. */
  62184. colorSteps: GradientBlockColorStep[];
  62185. /**
  62186. * Creates a new GradientBlock
  62187. * @param name defines the block name
  62188. */
  62189. constructor(name: string);
  62190. /**
  62191. * Gets the current class name
  62192. * @returns the class name
  62193. */
  62194. getClassName(): string;
  62195. /**
  62196. * Gets the gradient input component
  62197. */
  62198. get gradient(): NodeMaterialConnectionPoint;
  62199. /**
  62200. * Gets the output component
  62201. */
  62202. get output(): NodeMaterialConnectionPoint;
  62203. private _writeColorConstant;
  62204. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62205. serialize(): any;
  62206. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62207. protected _dumpPropertiesCode(): string;
  62208. }
  62209. }
  62210. declare module BABYLON {
  62211. /**
  62212. * Block used to normalize lerp between 2 values
  62213. */
  62214. export class NLerpBlock extends NodeMaterialBlock {
  62215. /**
  62216. * Creates a new NLerpBlock
  62217. * @param name defines the block name
  62218. */
  62219. constructor(name: string);
  62220. /**
  62221. * Gets the current class name
  62222. * @returns the class name
  62223. */
  62224. getClassName(): string;
  62225. /**
  62226. * Gets the left operand input component
  62227. */
  62228. get left(): NodeMaterialConnectionPoint;
  62229. /**
  62230. * Gets the right operand input component
  62231. */
  62232. get right(): NodeMaterialConnectionPoint;
  62233. /**
  62234. * Gets the gradient operand input component
  62235. */
  62236. get gradient(): NodeMaterialConnectionPoint;
  62237. /**
  62238. * Gets the output component
  62239. */
  62240. get output(): NodeMaterialConnectionPoint;
  62241. protected _buildBlock(state: NodeMaterialBuildState): this;
  62242. }
  62243. }
  62244. declare module BABYLON {
  62245. /**
  62246. * block used to Generate a Worley Noise 3D Noise Pattern
  62247. */
  62248. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62249. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62250. manhattanDistance: boolean;
  62251. /**
  62252. * Creates a new WorleyNoise3DBlock
  62253. * @param name defines the block name
  62254. */
  62255. constructor(name: string);
  62256. /**
  62257. * Gets the current class name
  62258. * @returns the class name
  62259. */
  62260. getClassName(): string;
  62261. /**
  62262. * Gets the seed input component
  62263. */
  62264. get seed(): NodeMaterialConnectionPoint;
  62265. /**
  62266. * Gets the jitter input component
  62267. */
  62268. get jitter(): NodeMaterialConnectionPoint;
  62269. /**
  62270. * Gets the output component
  62271. */
  62272. get output(): NodeMaterialConnectionPoint;
  62273. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62274. /**
  62275. * Exposes the properties to the UI?
  62276. */
  62277. protected _dumpPropertiesCode(): string;
  62278. /**
  62279. * Exposes the properties to the Seralize?
  62280. */
  62281. serialize(): any;
  62282. /**
  62283. * Exposes the properties to the deseralize?
  62284. */
  62285. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62286. }
  62287. }
  62288. declare module BABYLON {
  62289. /**
  62290. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62291. */
  62292. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62293. /**
  62294. * Creates a new SimplexPerlin3DBlock
  62295. * @param name defines the block name
  62296. */
  62297. constructor(name: string);
  62298. /**
  62299. * Gets the current class name
  62300. * @returns the class name
  62301. */
  62302. getClassName(): string;
  62303. /**
  62304. * Gets the seed operand input component
  62305. */
  62306. get seed(): NodeMaterialConnectionPoint;
  62307. /**
  62308. * Gets the output component
  62309. */
  62310. get output(): NodeMaterialConnectionPoint;
  62311. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62312. }
  62313. }
  62314. declare module BABYLON {
  62315. /**
  62316. * Block used to blend normals
  62317. */
  62318. export class NormalBlendBlock extends NodeMaterialBlock {
  62319. /**
  62320. * Creates a new NormalBlendBlock
  62321. * @param name defines the block name
  62322. */
  62323. constructor(name: string);
  62324. /**
  62325. * Gets the current class name
  62326. * @returns the class name
  62327. */
  62328. getClassName(): string;
  62329. /**
  62330. * Gets the first input component
  62331. */
  62332. get normalMap0(): NodeMaterialConnectionPoint;
  62333. /**
  62334. * Gets the second input component
  62335. */
  62336. get normalMap1(): NodeMaterialConnectionPoint;
  62337. /**
  62338. * Gets the output component
  62339. */
  62340. get output(): NodeMaterialConnectionPoint;
  62341. protected _buildBlock(state: NodeMaterialBuildState): this;
  62342. }
  62343. }
  62344. declare module BABYLON {
  62345. /**
  62346. * Block used to rotate a 2d vector by a given angle
  62347. */
  62348. export class Rotate2dBlock extends NodeMaterialBlock {
  62349. /**
  62350. * Creates a new Rotate2dBlock
  62351. * @param name defines the block name
  62352. */
  62353. constructor(name: string);
  62354. /**
  62355. * Gets the current class name
  62356. * @returns the class name
  62357. */
  62358. getClassName(): string;
  62359. /**
  62360. * Gets the input vector
  62361. */
  62362. get input(): NodeMaterialConnectionPoint;
  62363. /**
  62364. * Gets the input angle
  62365. */
  62366. get angle(): NodeMaterialConnectionPoint;
  62367. /**
  62368. * Gets the output component
  62369. */
  62370. get output(): NodeMaterialConnectionPoint;
  62371. autoConfigure(material: NodeMaterial): void;
  62372. protected _buildBlock(state: NodeMaterialBuildState): this;
  62373. }
  62374. }
  62375. declare module BABYLON {
  62376. /**
  62377. * Block used to get the reflected vector from a direction and a normal
  62378. */
  62379. export class ReflectBlock extends NodeMaterialBlock {
  62380. /**
  62381. * Creates a new ReflectBlock
  62382. * @param name defines the block name
  62383. */
  62384. constructor(name: string);
  62385. /**
  62386. * Gets the current class name
  62387. * @returns the class name
  62388. */
  62389. getClassName(): string;
  62390. /**
  62391. * Gets the incident component
  62392. */
  62393. get incident(): NodeMaterialConnectionPoint;
  62394. /**
  62395. * Gets the normal component
  62396. */
  62397. get normal(): NodeMaterialConnectionPoint;
  62398. /**
  62399. * Gets the output component
  62400. */
  62401. get output(): NodeMaterialConnectionPoint;
  62402. protected _buildBlock(state: NodeMaterialBuildState): this;
  62403. }
  62404. }
  62405. declare module BABYLON {
  62406. /**
  62407. * Block used to get the refracted vector from a direction and a normal
  62408. */
  62409. export class RefractBlock extends NodeMaterialBlock {
  62410. /**
  62411. * Creates a new RefractBlock
  62412. * @param name defines the block name
  62413. */
  62414. constructor(name: string);
  62415. /**
  62416. * Gets the current class name
  62417. * @returns the class name
  62418. */
  62419. getClassName(): string;
  62420. /**
  62421. * Gets the incident component
  62422. */
  62423. get incident(): NodeMaterialConnectionPoint;
  62424. /**
  62425. * Gets the normal component
  62426. */
  62427. get normal(): NodeMaterialConnectionPoint;
  62428. /**
  62429. * Gets the index of refraction component
  62430. */
  62431. get ior(): NodeMaterialConnectionPoint;
  62432. /**
  62433. * Gets the output component
  62434. */
  62435. get output(): NodeMaterialConnectionPoint;
  62436. protected _buildBlock(state: NodeMaterialBuildState): this;
  62437. }
  62438. }
  62439. declare module BABYLON {
  62440. /**
  62441. * Block used to desaturate a color
  62442. */
  62443. export class DesaturateBlock extends NodeMaterialBlock {
  62444. /**
  62445. * Creates a new DesaturateBlock
  62446. * @param name defines the block name
  62447. */
  62448. constructor(name: string);
  62449. /**
  62450. * Gets the current class name
  62451. * @returns the class name
  62452. */
  62453. getClassName(): string;
  62454. /**
  62455. * Gets the color operand input component
  62456. */
  62457. get color(): NodeMaterialConnectionPoint;
  62458. /**
  62459. * Gets the level operand input component
  62460. */
  62461. get level(): NodeMaterialConnectionPoint;
  62462. /**
  62463. * Gets the output component
  62464. */
  62465. get output(): NodeMaterialConnectionPoint;
  62466. protected _buildBlock(state: NodeMaterialBuildState): this;
  62467. }
  62468. }
  62469. declare module BABYLON {
  62470. /**
  62471. * Block used to implement the ambient occlusion module of the PBR material
  62472. */
  62473. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62474. /**
  62475. * Create a new AmbientOcclusionBlock
  62476. * @param name defines the block name
  62477. */
  62478. constructor(name: string);
  62479. /**
  62480. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62481. */
  62482. useAmbientInGrayScale: boolean;
  62483. /**
  62484. * Initialize the block and prepare the context for build
  62485. * @param state defines the state that will be used for the build
  62486. */
  62487. initialize(state: NodeMaterialBuildState): void;
  62488. /**
  62489. * Gets the current class name
  62490. * @returns the class name
  62491. */
  62492. getClassName(): string;
  62493. /**
  62494. * Gets the texture input component
  62495. */
  62496. get texture(): NodeMaterialConnectionPoint;
  62497. /**
  62498. * Gets the texture intensity component
  62499. */
  62500. get intensity(): NodeMaterialConnectionPoint;
  62501. /**
  62502. * Gets the direct light intensity input component
  62503. */
  62504. get directLightIntensity(): NodeMaterialConnectionPoint;
  62505. /**
  62506. * Gets the ambient occlusion object output component
  62507. */
  62508. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62509. /**
  62510. * Gets the main code of the block (fragment side)
  62511. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  62512. * @returns the shader code
  62513. */
  62514. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  62515. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62516. protected _buildBlock(state: NodeMaterialBuildState): this;
  62517. protected _dumpPropertiesCode(): string;
  62518. serialize(): any;
  62519. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62520. }
  62521. }
  62522. declare module BABYLON {
  62523. /**
  62524. * Block used to implement the reflection module of the PBR material
  62525. */
  62526. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  62527. /** @hidden */
  62528. _defineLODReflectionAlpha: string;
  62529. /** @hidden */
  62530. _defineLinearSpecularReflection: string;
  62531. private _vEnvironmentIrradianceName;
  62532. /** @hidden */
  62533. _vReflectionMicrosurfaceInfosName: string;
  62534. /** @hidden */
  62535. _vReflectionInfosName: string;
  62536. private _scene;
  62537. /**
  62538. * The three properties below are set by the main PBR block prior to calling methods of this class.
  62539. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62540. * It's less burden on the user side in the editor part.
  62541. */
  62542. /** @hidden */
  62543. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62544. /** @hidden */
  62545. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62546. /** @hidden */
  62547. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  62548. /**
  62549. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  62550. * diffuse part of the IBL.
  62551. */
  62552. useSphericalHarmonics: boolean;
  62553. /**
  62554. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  62555. */
  62556. forceIrradianceInFragment: boolean;
  62557. /**
  62558. * Create a new ReflectionBlock
  62559. * @param name defines the block name
  62560. */
  62561. constructor(name: string);
  62562. /**
  62563. * Gets the current class name
  62564. * @returns the class name
  62565. */
  62566. getClassName(): string;
  62567. /**
  62568. * Gets the position input component
  62569. */
  62570. get position(): NodeMaterialConnectionPoint;
  62571. /**
  62572. * Gets the world position input component
  62573. */
  62574. get worldPosition(): NodeMaterialConnectionPoint;
  62575. /**
  62576. * Gets the world normal input component
  62577. */
  62578. get worldNormal(): NodeMaterialConnectionPoint;
  62579. /**
  62580. * Gets the world input component
  62581. */
  62582. get world(): NodeMaterialConnectionPoint;
  62583. /**
  62584. * Gets the camera (or eye) position component
  62585. */
  62586. get cameraPosition(): NodeMaterialConnectionPoint;
  62587. /**
  62588. * Gets the view input component
  62589. */
  62590. get view(): NodeMaterialConnectionPoint;
  62591. /**
  62592. * Gets the color input component
  62593. */
  62594. get color(): NodeMaterialConnectionPoint;
  62595. /**
  62596. * Gets the reflection object output component
  62597. */
  62598. get reflection(): NodeMaterialConnectionPoint;
  62599. /**
  62600. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  62601. */
  62602. get hasTexture(): boolean;
  62603. /**
  62604. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  62605. */
  62606. get reflectionColor(): string;
  62607. protected _getTexture(): Nullable<BaseTexture>;
  62608. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62609. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62610. /**
  62611. * Gets the code to inject in the vertex shader
  62612. * @param state current state of the node material building
  62613. * @returns the shader code
  62614. */
  62615. handleVertexSide(state: NodeMaterialBuildState): string;
  62616. /**
  62617. * Gets the main code of the block (fragment side)
  62618. * @param state current state of the node material building
  62619. * @param normalVarName name of the existing variable corresponding to the normal
  62620. * @returns the shader code
  62621. */
  62622. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  62623. protected _buildBlock(state: NodeMaterialBuildState): this;
  62624. protected _dumpPropertiesCode(): string;
  62625. serialize(): any;
  62626. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62627. }
  62628. }
  62629. declare module BABYLON {
  62630. /**
  62631. * Block used to implement the sheen module of the PBR material
  62632. */
  62633. export class SheenBlock extends NodeMaterialBlock {
  62634. /**
  62635. * Create a new SheenBlock
  62636. * @param name defines the block name
  62637. */
  62638. constructor(name: string);
  62639. /**
  62640. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  62641. * It allows the strength of the sheen effect to not depend on the base color of the material,
  62642. * making it easier to setup and tweak the effect
  62643. */
  62644. albedoScaling: boolean;
  62645. /**
  62646. * Defines if the sheen is linked to the sheen color.
  62647. */
  62648. linkSheenWithAlbedo: boolean;
  62649. /**
  62650. * Initialize the block and prepare the context for build
  62651. * @param state defines the state that will be used for the build
  62652. */
  62653. initialize(state: NodeMaterialBuildState): void;
  62654. /**
  62655. * Gets the current class name
  62656. * @returns the class name
  62657. */
  62658. getClassName(): string;
  62659. /**
  62660. * Gets the intensity input component
  62661. */
  62662. get intensity(): NodeMaterialConnectionPoint;
  62663. /**
  62664. * Gets the color input component
  62665. */
  62666. get color(): NodeMaterialConnectionPoint;
  62667. /**
  62668. * Gets the roughness input component
  62669. */
  62670. get roughness(): NodeMaterialConnectionPoint;
  62671. /**
  62672. * Gets the texture input component
  62673. */
  62674. get texture(): NodeMaterialConnectionPoint;
  62675. /**
  62676. * Gets the sheen object output component
  62677. */
  62678. get sheen(): NodeMaterialConnectionPoint;
  62679. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62680. /**
  62681. * Gets the main code of the block (fragment side)
  62682. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62683. * @returns the shader code
  62684. */
  62685. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  62686. protected _buildBlock(state: NodeMaterialBuildState): this;
  62687. protected _dumpPropertiesCode(): string;
  62688. serialize(): any;
  62689. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62690. }
  62691. }
  62692. declare module BABYLON {
  62693. /**
  62694. * Block used to implement the reflectivity module of the PBR material
  62695. */
  62696. export class ReflectivityBlock extends NodeMaterialBlock {
  62697. /**
  62698. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  62699. */
  62700. useAmbientOcclusionFromMetallicTextureRed: boolean;
  62701. /**
  62702. * Specifies if the metallic texture contains the metallness information in its blue channel.
  62703. */
  62704. useMetallnessFromMetallicTextureBlue: boolean;
  62705. /**
  62706. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  62707. */
  62708. useRoughnessFromMetallicTextureAlpha: boolean;
  62709. /**
  62710. * Specifies if the metallic texture contains the roughness information in its green channel.
  62711. */
  62712. useRoughnessFromMetallicTextureGreen: boolean;
  62713. /**
  62714. * Create a new ReflectivityBlock
  62715. * @param name defines the block name
  62716. */
  62717. constructor(name: string);
  62718. /**
  62719. * Initialize the block and prepare the context for build
  62720. * @param state defines the state that will be used for the build
  62721. */
  62722. initialize(state: NodeMaterialBuildState): void;
  62723. /**
  62724. * Gets the current class name
  62725. * @returns the class name
  62726. */
  62727. getClassName(): string;
  62728. /**
  62729. * Gets the metallic input component
  62730. */
  62731. get metallic(): NodeMaterialConnectionPoint;
  62732. /**
  62733. * Gets the roughness input component
  62734. */
  62735. get roughness(): NodeMaterialConnectionPoint;
  62736. /**
  62737. * Gets the texture input component
  62738. */
  62739. get texture(): NodeMaterialConnectionPoint;
  62740. /**
  62741. * Gets the reflectivity object output component
  62742. */
  62743. get reflectivity(): NodeMaterialConnectionPoint;
  62744. /**
  62745. * Gets the main code of the block (fragment side)
  62746. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  62747. * @returns the shader code
  62748. */
  62749. getCode(aoIntensityVarName: string): string;
  62750. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62751. protected _buildBlock(state: NodeMaterialBuildState): this;
  62752. protected _dumpPropertiesCode(): string;
  62753. serialize(): any;
  62754. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62755. }
  62756. }
  62757. declare module BABYLON {
  62758. /**
  62759. * Block used to implement the anisotropy module of the PBR material
  62760. */
  62761. export class AnisotropyBlock extends NodeMaterialBlock {
  62762. /**
  62763. * The two properties below are set by the main PBR block prior to calling methods of this class.
  62764. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  62765. * It's less burden on the user side in the editor part.
  62766. */
  62767. /** @hidden */
  62768. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  62769. /** @hidden */
  62770. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  62771. /**
  62772. * Create a new AnisotropyBlock
  62773. * @param name defines the block name
  62774. */
  62775. constructor(name: string);
  62776. /**
  62777. * Initialize the block and prepare the context for build
  62778. * @param state defines the state that will be used for the build
  62779. */
  62780. initialize(state: NodeMaterialBuildState): void;
  62781. /**
  62782. * Gets the current class name
  62783. * @returns the class name
  62784. */
  62785. getClassName(): string;
  62786. /**
  62787. * Gets the intensity input component
  62788. */
  62789. get intensity(): NodeMaterialConnectionPoint;
  62790. /**
  62791. * Gets the direction input component
  62792. */
  62793. get direction(): NodeMaterialConnectionPoint;
  62794. /**
  62795. * Gets the texture input component
  62796. */
  62797. get texture(): NodeMaterialConnectionPoint;
  62798. /**
  62799. * Gets the uv input component
  62800. */
  62801. get uv(): NodeMaterialConnectionPoint;
  62802. /**
  62803. * Gets the worldTangent input component
  62804. */
  62805. get worldTangent(): NodeMaterialConnectionPoint;
  62806. /**
  62807. * Gets the anisotropy object output component
  62808. */
  62809. get anisotropy(): NodeMaterialConnectionPoint;
  62810. private _generateTBNSpace;
  62811. /**
  62812. * Gets the main code of the block (fragment side)
  62813. * @param state current state of the node material building
  62814. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62815. * @returns the shader code
  62816. */
  62817. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  62818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62819. protected _buildBlock(state: NodeMaterialBuildState): this;
  62820. }
  62821. }
  62822. declare module BABYLON {
  62823. /**
  62824. * Block used to implement the clear coat module of the PBR material
  62825. */
  62826. export class ClearCoatBlock extends NodeMaterialBlock {
  62827. private _scene;
  62828. /**
  62829. * Create a new ClearCoatBlock
  62830. * @param name defines the block name
  62831. */
  62832. constructor(name: string);
  62833. /**
  62834. * Initialize the block and prepare the context for build
  62835. * @param state defines the state that will be used for the build
  62836. */
  62837. initialize(state: NodeMaterialBuildState): void;
  62838. /**
  62839. * Gets the current class name
  62840. * @returns the class name
  62841. */
  62842. getClassName(): string;
  62843. /**
  62844. * Gets the intensity input component
  62845. */
  62846. get intensity(): NodeMaterialConnectionPoint;
  62847. /**
  62848. * Gets the roughness input component
  62849. */
  62850. get roughness(): NodeMaterialConnectionPoint;
  62851. /**
  62852. * Gets the ior input component
  62853. */
  62854. get ior(): NodeMaterialConnectionPoint;
  62855. /**
  62856. * Gets the texture input component
  62857. */
  62858. get texture(): NodeMaterialConnectionPoint;
  62859. /**
  62860. * Gets the bump texture input component
  62861. */
  62862. get bumpTexture(): NodeMaterialConnectionPoint;
  62863. /**
  62864. * Gets the uv input component
  62865. */
  62866. get uv(): NodeMaterialConnectionPoint;
  62867. /**
  62868. * Gets the tint color input component
  62869. */
  62870. get tintColor(): NodeMaterialConnectionPoint;
  62871. /**
  62872. * Gets the tint "at distance" input component
  62873. */
  62874. get tintAtDistance(): NodeMaterialConnectionPoint;
  62875. /**
  62876. * Gets the tint thickness input component
  62877. */
  62878. get tintThickness(): NodeMaterialConnectionPoint;
  62879. /**
  62880. * Gets the tint texture input component
  62881. */
  62882. get tintTexture(): NodeMaterialConnectionPoint;
  62883. /**
  62884. * Gets the world tangent input component
  62885. */
  62886. get worldTangent(): NodeMaterialConnectionPoint;
  62887. /**
  62888. * Gets the clear coat object output component
  62889. */
  62890. get clearcoat(): NodeMaterialConnectionPoint;
  62891. autoConfigure(material: NodeMaterial): void;
  62892. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62893. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  62894. private _generateTBNSpace;
  62895. /**
  62896. * Gets the main code of the block (fragment side)
  62897. * @param state current state of the node material building
  62898. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  62899. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62900. * @param worldPosVarName name of the variable holding the world position
  62901. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  62902. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  62903. * @param worldNormalVarName name of the variable holding the world normal
  62904. * @returns the shader code
  62905. */
  62906. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  62907. protected _buildBlock(state: NodeMaterialBuildState): this;
  62908. }
  62909. }
  62910. declare module BABYLON {
  62911. /**
  62912. * Block used to implement the sub surface module of the PBR material
  62913. */
  62914. export class SubSurfaceBlock extends NodeMaterialBlock {
  62915. /**
  62916. * Create a new SubSurfaceBlock
  62917. * @param name defines the block name
  62918. */
  62919. constructor(name: string);
  62920. /**
  62921. * Stores the intensity of the different subsurface effects in the thickness texture.
  62922. * * the green channel is the translucency intensity.
  62923. * * the blue channel is the scattering intensity.
  62924. * * the alpha channel is the refraction intensity.
  62925. */
  62926. useMaskFromThicknessTexture: boolean;
  62927. /**
  62928. * Initialize the block and prepare the context for build
  62929. * @param state defines the state that will be used for the build
  62930. */
  62931. initialize(state: NodeMaterialBuildState): void;
  62932. /**
  62933. * Gets the current class name
  62934. * @returns the class name
  62935. */
  62936. getClassName(): string;
  62937. /**
  62938. * Gets the min thickness input component
  62939. */
  62940. get minThickness(): NodeMaterialConnectionPoint;
  62941. /**
  62942. * Gets the max thickness input component
  62943. */
  62944. get maxThickness(): NodeMaterialConnectionPoint;
  62945. /**
  62946. * Gets the thickness texture component
  62947. */
  62948. get thicknessTexture(): NodeMaterialConnectionPoint;
  62949. /**
  62950. * Gets the tint color input component
  62951. */
  62952. get tintColor(): NodeMaterialConnectionPoint;
  62953. /**
  62954. * Gets the translucency intensity input component
  62955. */
  62956. get translucencyIntensity(): NodeMaterialConnectionPoint;
  62957. /**
  62958. * Gets the translucency diffusion distance input component
  62959. */
  62960. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  62961. /**
  62962. * Gets the refraction object parameters
  62963. */
  62964. get refraction(): NodeMaterialConnectionPoint;
  62965. /**
  62966. * Gets the sub surface object output component
  62967. */
  62968. get subsurface(): NodeMaterialConnectionPoint;
  62969. autoConfigure(material: NodeMaterial): void;
  62970. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62971. /**
  62972. * Gets the main code of the block (fragment side)
  62973. * @param state current state of the node material building
  62974. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  62975. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  62976. * @param worldPosVarName name of the variable holding the world position
  62977. * @returns the shader code
  62978. */
  62979. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  62980. protected _buildBlock(state: NodeMaterialBuildState): this;
  62981. }
  62982. }
  62983. declare module BABYLON {
  62984. /**
  62985. * Block used to implement the PBR metallic/roughness model
  62986. */
  62987. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  62988. /**
  62989. * Gets or sets the light associated with this block
  62990. */
  62991. light: Nullable<Light>;
  62992. private _lightId;
  62993. private _scene;
  62994. private _environmentBRDFTexture;
  62995. private _environmentBrdfSamplerName;
  62996. private _vNormalWName;
  62997. private _invertNormalName;
  62998. /**
  62999. * Create a new ReflectionBlock
  63000. * @param name defines the block name
  63001. */
  63002. constructor(name: string);
  63003. /**
  63004. * Intensity of the direct lights e.g. the four lights available in your scene.
  63005. * This impacts both the direct diffuse and specular highlights.
  63006. */
  63007. directIntensity: number;
  63008. /**
  63009. * Intensity of the environment e.g. how much the environment will light the object
  63010. * either through harmonics for rough material or through the refelction for shiny ones.
  63011. */
  63012. environmentIntensity: number;
  63013. /**
  63014. * This is a special control allowing the reduction of the specular highlights coming from the
  63015. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63016. */
  63017. specularIntensity: number;
  63018. /**
  63019. * Defines the falloff type used in this material.
  63020. * It by default is Physical.
  63021. */
  63022. lightFalloff: number;
  63023. /**
  63024. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63025. */
  63026. useAlphaFromAlbedoTexture: boolean;
  63027. /**
  63028. * Specifies that alpha test should be used
  63029. */
  63030. useAlphaTest: boolean;
  63031. /**
  63032. * Defines the alpha limits in alpha test mode.
  63033. */
  63034. alphaTestCutoff: number;
  63035. /**
  63036. * Specifies that alpha blending should be used
  63037. */
  63038. useAlphaBlending: boolean;
  63039. /**
  63040. * Defines if the alpha value should be determined via the rgb values.
  63041. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63042. */
  63043. opacityRGB: boolean;
  63044. /**
  63045. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63046. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63047. */
  63048. useRadianceOverAlpha: boolean;
  63049. /**
  63050. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63051. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63052. */
  63053. useSpecularOverAlpha: boolean;
  63054. /**
  63055. * Enables specular anti aliasing in the PBR shader.
  63056. * It will both interacts on the Geometry for analytical and IBL lighting.
  63057. * It also prefilter the roughness map based on the bump values.
  63058. */
  63059. enableSpecularAntiAliasing: boolean;
  63060. /**
  63061. * Defines if the material uses energy conservation.
  63062. */
  63063. useEnergyConservation: boolean;
  63064. /**
  63065. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63066. * too much the area relying on ambient texture to define their ambient occlusion.
  63067. */
  63068. useRadianceOcclusion: boolean;
  63069. /**
  63070. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63071. * makes the reflect vector face the model (under horizon).
  63072. */
  63073. useHorizonOcclusion: boolean;
  63074. /**
  63075. * If set to true, no lighting calculations will be applied.
  63076. */
  63077. unlit: boolean;
  63078. /**
  63079. * Force normal to face away from face.
  63080. */
  63081. forceNormalForward: boolean;
  63082. /**
  63083. * Defines the material debug mode.
  63084. * It helps seeing only some components of the material while troubleshooting.
  63085. */
  63086. debugMode: number;
  63087. /**
  63088. * Specify from where on screen the debug mode should start.
  63089. * The value goes from -1 (full screen) to 1 (not visible)
  63090. * It helps with side by side comparison against the final render
  63091. * This defaults to 0
  63092. */
  63093. debugLimit: number;
  63094. /**
  63095. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63096. * You can use the factor to better multiply the final value.
  63097. */
  63098. debugFactor: number;
  63099. /**
  63100. * Initialize the block and prepare the context for build
  63101. * @param state defines the state that will be used for the build
  63102. */
  63103. initialize(state: NodeMaterialBuildState): void;
  63104. /**
  63105. * Gets the current class name
  63106. * @returns the class name
  63107. */
  63108. getClassName(): string;
  63109. /**
  63110. * Gets the world position input component
  63111. */
  63112. get worldPosition(): NodeMaterialConnectionPoint;
  63113. /**
  63114. * Gets the world normal input component
  63115. */
  63116. get worldNormal(): NodeMaterialConnectionPoint;
  63117. /**
  63118. * Gets the perturbed normal input component
  63119. */
  63120. get perturbedNormal(): NodeMaterialConnectionPoint;
  63121. /**
  63122. * Gets the camera position input component
  63123. */
  63124. get cameraPosition(): NodeMaterialConnectionPoint;
  63125. /**
  63126. * Gets the base color input component
  63127. */
  63128. get baseColor(): NodeMaterialConnectionPoint;
  63129. /**
  63130. * Gets the base texture input component
  63131. */
  63132. get baseTexture(): NodeMaterialConnectionPoint;
  63133. /**
  63134. * Gets the opacity texture input component
  63135. */
  63136. get opacityTexture(): NodeMaterialConnectionPoint;
  63137. /**
  63138. * Gets the ambient color input component
  63139. */
  63140. get ambientColor(): NodeMaterialConnectionPoint;
  63141. /**
  63142. * Gets the reflectivity object parameters
  63143. */
  63144. get reflectivity(): NodeMaterialConnectionPoint;
  63145. /**
  63146. * Gets the ambient occlusion object parameters
  63147. */
  63148. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63149. /**
  63150. * Gets the reflection object parameters
  63151. */
  63152. get reflection(): NodeMaterialConnectionPoint;
  63153. /**
  63154. * Gets the sheen object parameters
  63155. */
  63156. get sheen(): NodeMaterialConnectionPoint;
  63157. /**
  63158. * Gets the clear coat object parameters
  63159. */
  63160. get clearcoat(): NodeMaterialConnectionPoint;
  63161. /**
  63162. * Gets the sub surface object parameters
  63163. */
  63164. get subsurface(): NodeMaterialConnectionPoint;
  63165. /**
  63166. * Gets the anisotropy object parameters
  63167. */
  63168. get anisotropy(): NodeMaterialConnectionPoint;
  63169. /**
  63170. * Gets the ambient output component
  63171. */
  63172. get ambient(): NodeMaterialConnectionPoint;
  63173. /**
  63174. * Gets the diffuse output component
  63175. */
  63176. get diffuse(): NodeMaterialConnectionPoint;
  63177. /**
  63178. * Gets the specular output component
  63179. */
  63180. get specular(): NodeMaterialConnectionPoint;
  63181. /**
  63182. * Gets the sheen output component
  63183. */
  63184. get sheenDir(): NodeMaterialConnectionPoint;
  63185. /**
  63186. * Gets the clear coat output component
  63187. */
  63188. get clearcoatDir(): NodeMaterialConnectionPoint;
  63189. /**
  63190. * Gets the indirect diffuse output component
  63191. */
  63192. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63193. /**
  63194. * Gets the indirect specular output component
  63195. */
  63196. get specularIndirect(): NodeMaterialConnectionPoint;
  63197. /**
  63198. * Gets the indirect sheen output component
  63199. */
  63200. get sheenIndirect(): NodeMaterialConnectionPoint;
  63201. /**
  63202. * Gets the indirect clear coat output component
  63203. */
  63204. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63205. /**
  63206. * Gets the refraction output component
  63207. */
  63208. get refraction(): NodeMaterialConnectionPoint;
  63209. /**
  63210. * Gets the global lighting output component
  63211. */
  63212. get lighting(): NodeMaterialConnectionPoint;
  63213. /**
  63214. * Gets the shadow output component
  63215. */
  63216. get shadow(): NodeMaterialConnectionPoint;
  63217. /**
  63218. * Gets the alpha output component
  63219. */
  63220. get alpha(): NodeMaterialConnectionPoint;
  63221. autoConfigure(material: NodeMaterial): void;
  63222. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63223. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63224. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63225. private _injectVertexCode;
  63226. /**
  63227. * Gets the code corresponding to the albedo/opacity module
  63228. * @returns the shader code
  63229. */
  63230. getAlbedoOpacityCode(): string;
  63231. protected _buildBlock(state: NodeMaterialBuildState): this;
  63232. protected _dumpPropertiesCode(): string;
  63233. serialize(): any;
  63234. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63235. }
  63236. }
  63237. declare module BABYLON {
  63238. /**
  63239. * Block used to compute value of one parameter modulo another
  63240. */
  63241. export class ModBlock extends NodeMaterialBlock {
  63242. /**
  63243. * Creates a new ModBlock
  63244. * @param name defines the block name
  63245. */
  63246. constructor(name: string);
  63247. /**
  63248. * Gets the current class name
  63249. * @returns the class name
  63250. */
  63251. getClassName(): string;
  63252. /**
  63253. * Gets the left operand input component
  63254. */
  63255. get left(): NodeMaterialConnectionPoint;
  63256. /**
  63257. * Gets the right operand input component
  63258. */
  63259. get right(): NodeMaterialConnectionPoint;
  63260. /**
  63261. * Gets the output component
  63262. */
  63263. get output(): NodeMaterialConnectionPoint;
  63264. protected _buildBlock(state: NodeMaterialBuildState): this;
  63265. }
  63266. }
  63267. declare module BABYLON {
  63268. /**
  63269. * Helper class to push actions to a pool of workers.
  63270. */
  63271. export class WorkerPool implements IDisposable {
  63272. private _workerInfos;
  63273. private _pendingActions;
  63274. /**
  63275. * Constructor
  63276. * @param workers Array of workers to use for actions
  63277. */
  63278. constructor(workers: Array<Worker>);
  63279. /**
  63280. * Terminates all workers and clears any pending actions.
  63281. */
  63282. dispose(): void;
  63283. /**
  63284. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63285. * pended until a worker has completed its action.
  63286. * @param action The action to perform. Call onComplete when the action is complete.
  63287. */
  63288. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63289. private _execute;
  63290. }
  63291. }
  63292. declare module BABYLON {
  63293. /**
  63294. * Configuration for Draco compression
  63295. */
  63296. export interface IDracoCompressionConfiguration {
  63297. /**
  63298. * Configuration for the decoder.
  63299. */
  63300. decoder: {
  63301. /**
  63302. * The url to the WebAssembly module.
  63303. */
  63304. wasmUrl?: string;
  63305. /**
  63306. * The url to the WebAssembly binary.
  63307. */
  63308. wasmBinaryUrl?: string;
  63309. /**
  63310. * The url to the fallback JavaScript module.
  63311. */
  63312. fallbackUrl?: string;
  63313. };
  63314. }
  63315. /**
  63316. * Draco compression (https://google.github.io/draco/)
  63317. *
  63318. * This class wraps the Draco module.
  63319. *
  63320. * **Encoder**
  63321. *
  63322. * The encoder is not currently implemented.
  63323. *
  63324. * **Decoder**
  63325. *
  63326. * 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.
  63327. *
  63328. * To update the configuration, use the following code:
  63329. * ```javascript
  63330. * DracoCompression.Configuration = {
  63331. * decoder: {
  63332. * wasmUrl: "<url to the WebAssembly library>",
  63333. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63334. * fallbackUrl: "<url to the fallback JavaScript library>",
  63335. * }
  63336. * };
  63337. * ```
  63338. *
  63339. * 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.
  63340. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63341. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63342. *
  63343. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63344. * ```javascript
  63345. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63346. * ```
  63347. *
  63348. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63349. */
  63350. export class DracoCompression implements IDisposable {
  63351. private _workerPoolPromise?;
  63352. private _decoderModulePromise?;
  63353. /**
  63354. * The configuration. Defaults to the following urls:
  63355. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63356. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63357. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63358. */
  63359. static Configuration: IDracoCompressionConfiguration;
  63360. /**
  63361. * Returns true if the decoder configuration is available.
  63362. */
  63363. static get DecoderAvailable(): boolean;
  63364. /**
  63365. * Default number of workers to create when creating the draco compression object.
  63366. */
  63367. static DefaultNumWorkers: number;
  63368. private static GetDefaultNumWorkers;
  63369. private static _Default;
  63370. /**
  63371. * Default instance for the draco compression object.
  63372. */
  63373. static get Default(): DracoCompression;
  63374. /**
  63375. * Constructor
  63376. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63377. */
  63378. constructor(numWorkers?: number);
  63379. /**
  63380. * Stop all async operations and release resources.
  63381. */
  63382. dispose(): void;
  63383. /**
  63384. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63385. * @returns a promise that resolves when ready
  63386. */
  63387. whenReadyAsync(): Promise<void>;
  63388. /**
  63389. * Decode Draco compressed mesh data to vertex data.
  63390. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63391. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63392. * @returns A promise that resolves with the decoded vertex data
  63393. */
  63394. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63395. [kind: string]: number;
  63396. }): Promise<VertexData>;
  63397. }
  63398. }
  63399. declare module BABYLON {
  63400. /**
  63401. * Class for building Constructive Solid Geometry
  63402. */
  63403. export class CSG {
  63404. private polygons;
  63405. /**
  63406. * The world matrix
  63407. */
  63408. matrix: Matrix;
  63409. /**
  63410. * Stores the position
  63411. */
  63412. position: Vector3;
  63413. /**
  63414. * Stores the rotation
  63415. */
  63416. rotation: Vector3;
  63417. /**
  63418. * Stores the rotation quaternion
  63419. */
  63420. rotationQuaternion: Nullable<Quaternion>;
  63421. /**
  63422. * Stores the scaling vector
  63423. */
  63424. scaling: Vector3;
  63425. /**
  63426. * Convert the Mesh to CSG
  63427. * @param mesh The Mesh to convert to CSG
  63428. * @returns A new CSG from the Mesh
  63429. */
  63430. static FromMesh(mesh: Mesh): CSG;
  63431. /**
  63432. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63433. * @param polygons Polygons used to construct a CSG solid
  63434. */
  63435. private static FromPolygons;
  63436. /**
  63437. * Clones, or makes a deep copy, of the CSG
  63438. * @returns A new CSG
  63439. */
  63440. clone(): CSG;
  63441. /**
  63442. * Unions this CSG with another CSG
  63443. * @param csg The CSG to union against this CSG
  63444. * @returns The unioned CSG
  63445. */
  63446. union(csg: CSG): CSG;
  63447. /**
  63448. * Unions this CSG with another CSG in place
  63449. * @param csg The CSG to union against this CSG
  63450. */
  63451. unionInPlace(csg: CSG): void;
  63452. /**
  63453. * Subtracts this CSG with another CSG
  63454. * @param csg The CSG to subtract against this CSG
  63455. * @returns A new CSG
  63456. */
  63457. subtract(csg: CSG): CSG;
  63458. /**
  63459. * Subtracts this CSG with another CSG in place
  63460. * @param csg The CSG to subtact against this CSG
  63461. */
  63462. subtractInPlace(csg: CSG): void;
  63463. /**
  63464. * Intersect this CSG with another CSG
  63465. * @param csg The CSG to intersect against this CSG
  63466. * @returns A new CSG
  63467. */
  63468. intersect(csg: CSG): CSG;
  63469. /**
  63470. * Intersects this CSG with another CSG in place
  63471. * @param csg The CSG to intersect against this CSG
  63472. */
  63473. intersectInPlace(csg: CSG): void;
  63474. /**
  63475. * Return a new CSG solid with solid and empty space switched. This solid is
  63476. * not modified.
  63477. * @returns A new CSG solid with solid and empty space switched
  63478. */
  63479. inverse(): CSG;
  63480. /**
  63481. * Inverses the CSG in place
  63482. */
  63483. inverseInPlace(): void;
  63484. /**
  63485. * This is used to keep meshes transformations so they can be restored
  63486. * when we build back a Babylon Mesh
  63487. * NB : All CSG operations are performed in world coordinates
  63488. * @param csg The CSG to copy the transform attributes from
  63489. * @returns This CSG
  63490. */
  63491. copyTransformAttributes(csg: CSG): CSG;
  63492. /**
  63493. * Build Raw mesh from CSG
  63494. * Coordinates here are in world space
  63495. * @param name The name of the mesh geometry
  63496. * @param scene The Scene
  63497. * @param keepSubMeshes Specifies if the submeshes should be kept
  63498. * @returns A new Mesh
  63499. */
  63500. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63501. /**
  63502. * Build Mesh from CSG taking material and transforms into account
  63503. * @param name The name of the Mesh
  63504. * @param material The material of the Mesh
  63505. * @param scene The Scene
  63506. * @param keepSubMeshes Specifies if submeshes should be kept
  63507. * @returns The new Mesh
  63508. */
  63509. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63510. }
  63511. }
  63512. declare module BABYLON {
  63513. /**
  63514. * Class used to create a trail following a mesh
  63515. */
  63516. export class TrailMesh extends Mesh {
  63517. private _generator;
  63518. private _autoStart;
  63519. private _running;
  63520. private _diameter;
  63521. private _length;
  63522. private _sectionPolygonPointsCount;
  63523. private _sectionVectors;
  63524. private _sectionNormalVectors;
  63525. private _beforeRenderObserver;
  63526. /**
  63527. * @constructor
  63528. * @param name The value used by scene.getMeshByName() to do a lookup.
  63529. * @param generator The mesh or transform node to generate a trail.
  63530. * @param scene The scene to add this mesh to.
  63531. * @param diameter Diameter of trailing mesh. Default is 1.
  63532. * @param length Length of trailing mesh. Default is 60.
  63533. * @param autoStart Automatically start trailing mesh. Default true.
  63534. */
  63535. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63536. /**
  63537. * "TrailMesh"
  63538. * @returns "TrailMesh"
  63539. */
  63540. getClassName(): string;
  63541. private _createMesh;
  63542. /**
  63543. * Start trailing mesh.
  63544. */
  63545. start(): void;
  63546. /**
  63547. * Stop trailing mesh.
  63548. */
  63549. stop(): void;
  63550. /**
  63551. * Update trailing mesh geometry.
  63552. */
  63553. update(): void;
  63554. /**
  63555. * Returns a new TrailMesh object.
  63556. * @param name is a string, the name given to the new mesh
  63557. * @param newGenerator use new generator object for cloned trail mesh
  63558. * @returns a new mesh
  63559. */
  63560. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63561. /**
  63562. * Serializes this trail mesh
  63563. * @param serializationObject object to write serialization to
  63564. */
  63565. serialize(serializationObject: any): void;
  63566. /**
  63567. * Parses a serialized trail mesh
  63568. * @param parsedMesh the serialized mesh
  63569. * @param scene the scene to create the trail mesh in
  63570. * @returns the created trail mesh
  63571. */
  63572. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63573. }
  63574. }
  63575. declare module BABYLON {
  63576. /**
  63577. * Class containing static functions to help procedurally build meshes
  63578. */
  63579. export class TiledBoxBuilder {
  63580. /**
  63581. * Creates a box mesh
  63582. * 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)
  63583. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63585. * * 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
  63586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63587. * @param name defines the name of the mesh
  63588. * @param options defines the options used to create the mesh
  63589. * @param scene defines the hosting scene
  63590. * @returns the box mesh
  63591. */
  63592. static CreateTiledBox(name: string, options: {
  63593. pattern?: number;
  63594. width?: number;
  63595. height?: number;
  63596. depth?: number;
  63597. tileSize?: number;
  63598. tileWidth?: number;
  63599. tileHeight?: number;
  63600. alignHorizontal?: number;
  63601. alignVertical?: number;
  63602. faceUV?: Vector4[];
  63603. faceColors?: Color4[];
  63604. sideOrientation?: number;
  63605. updatable?: boolean;
  63606. }, scene?: Nullable<Scene>): Mesh;
  63607. }
  63608. }
  63609. declare module BABYLON {
  63610. /**
  63611. * Class containing static functions to help procedurally build meshes
  63612. */
  63613. export class TorusKnotBuilder {
  63614. /**
  63615. * Creates a torus knot mesh
  63616. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63617. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63618. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63619. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63620. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63621. * * 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
  63622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63623. * @param name defines the name of the mesh
  63624. * @param options defines the options used to create the mesh
  63625. * @param scene defines the hosting scene
  63626. * @returns the torus knot mesh
  63627. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63628. */
  63629. static CreateTorusKnot(name: string, options: {
  63630. radius?: number;
  63631. tube?: number;
  63632. radialSegments?: number;
  63633. tubularSegments?: number;
  63634. p?: number;
  63635. q?: number;
  63636. updatable?: boolean;
  63637. sideOrientation?: number;
  63638. frontUVs?: Vector4;
  63639. backUVs?: Vector4;
  63640. }, scene: any): Mesh;
  63641. }
  63642. }
  63643. declare module BABYLON {
  63644. /**
  63645. * Polygon
  63646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63647. */
  63648. export class Polygon {
  63649. /**
  63650. * Creates a rectangle
  63651. * @param xmin bottom X coord
  63652. * @param ymin bottom Y coord
  63653. * @param xmax top X coord
  63654. * @param ymax top Y coord
  63655. * @returns points that make the resulting rectation
  63656. */
  63657. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63658. /**
  63659. * Creates a circle
  63660. * @param radius radius of circle
  63661. * @param cx scale in x
  63662. * @param cy scale in y
  63663. * @param numberOfSides number of sides that make up the circle
  63664. * @returns points that make the resulting circle
  63665. */
  63666. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63667. /**
  63668. * Creates a polygon from input string
  63669. * @param input Input polygon data
  63670. * @returns the parsed points
  63671. */
  63672. static Parse(input: string): Vector2[];
  63673. /**
  63674. * Starts building a polygon from x and y coordinates
  63675. * @param x x coordinate
  63676. * @param y y coordinate
  63677. * @returns the started path2
  63678. */
  63679. static StartingAt(x: number, y: number): Path2;
  63680. }
  63681. /**
  63682. * Builds a polygon
  63683. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63684. */
  63685. export class PolygonMeshBuilder {
  63686. private _points;
  63687. private _outlinepoints;
  63688. private _holes;
  63689. private _name;
  63690. private _scene;
  63691. private _epoints;
  63692. private _eholes;
  63693. private _addToepoint;
  63694. /**
  63695. * Babylon reference to the earcut plugin.
  63696. */
  63697. bjsEarcut: any;
  63698. /**
  63699. * Creates a PolygonMeshBuilder
  63700. * @param name name of the builder
  63701. * @param contours Path of the polygon
  63702. * @param scene scene to add to when creating the mesh
  63703. * @param earcutInjection can be used to inject your own earcut reference
  63704. */
  63705. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63706. /**
  63707. * Adds a whole within the polygon
  63708. * @param hole Array of points defining the hole
  63709. * @returns this
  63710. */
  63711. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63712. /**
  63713. * Creates the polygon
  63714. * @param updatable If the mesh should be updatable
  63715. * @param depth The depth of the mesh created
  63716. * @returns the created mesh
  63717. */
  63718. build(updatable?: boolean, depth?: number): Mesh;
  63719. /**
  63720. * Creates the polygon
  63721. * @param depth The depth of the mesh created
  63722. * @returns the created VertexData
  63723. */
  63724. buildVertexData(depth?: number): VertexData;
  63725. /**
  63726. * Adds a side to the polygon
  63727. * @param positions points that make the polygon
  63728. * @param normals normals of the polygon
  63729. * @param uvs uvs of the polygon
  63730. * @param indices indices of the polygon
  63731. * @param bounds bounds of the polygon
  63732. * @param points points of the polygon
  63733. * @param depth depth of the polygon
  63734. * @param flip flip of the polygon
  63735. */
  63736. private addSide;
  63737. }
  63738. }
  63739. declare module BABYLON {
  63740. /**
  63741. * Class containing static functions to help procedurally build meshes
  63742. */
  63743. export class PolygonBuilder {
  63744. /**
  63745. * Creates a polygon mesh
  63746. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63747. * * 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
  63748. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63750. * * 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)
  63751. * * Remember you can only change the shape positions, not their number when updating a polygon
  63752. * @param name defines the name of the mesh
  63753. * @param options defines the options used to create the mesh
  63754. * @param scene defines the hosting scene
  63755. * @param earcutInjection can be used to inject your own earcut reference
  63756. * @returns the polygon mesh
  63757. */
  63758. static CreatePolygon(name: string, options: {
  63759. shape: Vector3[];
  63760. holes?: Vector3[][];
  63761. depth?: number;
  63762. faceUV?: Vector4[];
  63763. faceColors?: Color4[];
  63764. updatable?: boolean;
  63765. sideOrientation?: number;
  63766. frontUVs?: Vector4;
  63767. backUVs?: Vector4;
  63768. wrap?: boolean;
  63769. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63770. /**
  63771. * Creates an extruded polygon mesh, with depth in the Y direction.
  63772. * * 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)
  63773. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63774. * @param name defines the name of the mesh
  63775. * @param options defines the options used to create the mesh
  63776. * @param scene defines the hosting scene
  63777. * @param earcutInjection can be used to inject your own earcut reference
  63778. * @returns the polygon mesh
  63779. */
  63780. static ExtrudePolygon(name: string, options: {
  63781. shape: Vector3[];
  63782. holes?: Vector3[][];
  63783. depth?: number;
  63784. faceUV?: Vector4[];
  63785. faceColors?: Color4[];
  63786. updatable?: boolean;
  63787. sideOrientation?: number;
  63788. frontUVs?: Vector4;
  63789. backUVs?: Vector4;
  63790. wrap?: boolean;
  63791. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63792. }
  63793. }
  63794. declare module BABYLON {
  63795. /**
  63796. * Class containing static functions to help procedurally build meshes
  63797. */
  63798. export class LatheBuilder {
  63799. /**
  63800. * Creates lathe mesh.
  63801. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63802. * * 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
  63803. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63804. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63805. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63806. * * 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
  63807. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63808. * * 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
  63809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63810. * * 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
  63811. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63813. * @param name defines the name of the mesh
  63814. * @param options defines the options used to create the mesh
  63815. * @param scene defines the hosting scene
  63816. * @returns the lathe mesh
  63817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63818. */
  63819. static CreateLathe(name: string, options: {
  63820. shape: Vector3[];
  63821. radius?: number;
  63822. tessellation?: number;
  63823. clip?: number;
  63824. arc?: number;
  63825. closed?: boolean;
  63826. updatable?: boolean;
  63827. sideOrientation?: number;
  63828. frontUVs?: Vector4;
  63829. backUVs?: Vector4;
  63830. cap?: number;
  63831. invertUV?: boolean;
  63832. }, scene?: Nullable<Scene>): Mesh;
  63833. }
  63834. }
  63835. declare module BABYLON {
  63836. /**
  63837. * Class containing static functions to help procedurally build meshes
  63838. */
  63839. export class TiledPlaneBuilder {
  63840. /**
  63841. * Creates a tiled plane mesh
  63842. * * The parameter `pattern` will, depending on value, do nothing or
  63843. * * * flip (reflect about central vertical) alternate tiles across and up
  63844. * * * flip every tile on alternate rows
  63845. * * * rotate (180 degs) alternate tiles across and up
  63846. * * * rotate every tile on alternate rows
  63847. * * * flip and rotate alternate tiles across and up
  63848. * * * flip and rotate every tile on alternate rows
  63849. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63850. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63851. * * 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
  63852. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63853. * * 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)
  63854. * * 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)
  63855. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63856. * @param name defines the name of the mesh
  63857. * @param options defines the options used to create the mesh
  63858. * @param scene defines the hosting scene
  63859. * @returns the box mesh
  63860. */
  63861. static CreateTiledPlane(name: string, options: {
  63862. pattern?: number;
  63863. tileSize?: number;
  63864. tileWidth?: number;
  63865. tileHeight?: number;
  63866. size?: number;
  63867. width?: number;
  63868. height?: number;
  63869. alignHorizontal?: number;
  63870. alignVertical?: number;
  63871. sideOrientation?: number;
  63872. frontUVs?: Vector4;
  63873. backUVs?: Vector4;
  63874. updatable?: boolean;
  63875. }, scene?: Nullable<Scene>): Mesh;
  63876. }
  63877. }
  63878. declare module BABYLON {
  63879. /**
  63880. * Class containing static functions to help procedurally build meshes
  63881. */
  63882. export class TubeBuilder {
  63883. /**
  63884. * Creates a tube mesh.
  63885. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63886. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63887. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63888. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63889. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63890. * * 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)
  63891. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63892. * * 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
  63893. * * 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
  63894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63895. * * 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
  63896. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63898. * @param name defines the name of the mesh
  63899. * @param options defines the options used to create the mesh
  63900. * @param scene defines the hosting scene
  63901. * @returns the tube mesh
  63902. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63903. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63904. */
  63905. static CreateTube(name: string, options: {
  63906. path: Vector3[];
  63907. radius?: number;
  63908. tessellation?: number;
  63909. radiusFunction?: {
  63910. (i: number, distance: number): number;
  63911. };
  63912. cap?: number;
  63913. arc?: number;
  63914. updatable?: boolean;
  63915. sideOrientation?: number;
  63916. frontUVs?: Vector4;
  63917. backUVs?: Vector4;
  63918. instance?: Mesh;
  63919. invertUV?: boolean;
  63920. }, scene?: Nullable<Scene>): Mesh;
  63921. }
  63922. }
  63923. declare module BABYLON {
  63924. /**
  63925. * Class containing static functions to help procedurally build meshes
  63926. */
  63927. export class IcoSphereBuilder {
  63928. /**
  63929. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63930. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63931. * * 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`)
  63932. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63933. * * 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
  63934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63935. * * 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
  63936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63937. * @param name defines the name of the mesh
  63938. * @param options defines the options used to create the mesh
  63939. * @param scene defines the hosting scene
  63940. * @returns the icosahedron mesh
  63941. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63942. */
  63943. static CreateIcoSphere(name: string, options: {
  63944. radius?: number;
  63945. radiusX?: number;
  63946. radiusY?: number;
  63947. radiusZ?: number;
  63948. flat?: boolean;
  63949. subdivisions?: number;
  63950. sideOrientation?: number;
  63951. frontUVs?: Vector4;
  63952. backUVs?: Vector4;
  63953. updatable?: boolean;
  63954. }, scene?: Nullable<Scene>): Mesh;
  63955. }
  63956. }
  63957. declare module BABYLON {
  63958. /**
  63959. * Class containing static functions to help procedurally build meshes
  63960. */
  63961. export class DecalBuilder {
  63962. /**
  63963. * Creates a decal mesh.
  63964. * 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
  63965. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63966. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63967. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63968. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63969. * @param name defines the name of the mesh
  63970. * @param sourceMesh defines the mesh where the decal must be applied
  63971. * @param options defines the options used to create the mesh
  63972. * @param scene defines the hosting scene
  63973. * @returns the decal mesh
  63974. * @see https://doc.babylonjs.com/how_to/decals
  63975. */
  63976. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63977. position?: Vector3;
  63978. normal?: Vector3;
  63979. size?: Vector3;
  63980. angle?: number;
  63981. }): Mesh;
  63982. }
  63983. }
  63984. declare module BABYLON {
  63985. /**
  63986. * Class containing static functions to help procedurally build meshes
  63987. */
  63988. export class MeshBuilder {
  63989. /**
  63990. * Creates a box mesh
  63991. * * The parameter `size` sets the size (float) of each box side (default 1)
  63992. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63993. * * 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)
  63994. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63996. * * 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
  63997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63998. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63999. * @param name defines the name of the mesh
  64000. * @param options defines the options used to create the mesh
  64001. * @param scene defines the hosting scene
  64002. * @returns the box mesh
  64003. */
  64004. static CreateBox(name: string, options: {
  64005. size?: number;
  64006. width?: number;
  64007. height?: number;
  64008. depth?: number;
  64009. faceUV?: Vector4[];
  64010. faceColors?: Color4[];
  64011. sideOrientation?: number;
  64012. frontUVs?: Vector4;
  64013. backUVs?: Vector4;
  64014. wrap?: boolean;
  64015. topBaseAt?: number;
  64016. bottomBaseAt?: number;
  64017. updatable?: boolean;
  64018. }, scene?: Nullable<Scene>): Mesh;
  64019. /**
  64020. * Creates a tiled box mesh
  64021. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64023. * @param name defines the name of the mesh
  64024. * @param options defines the options used to create the mesh
  64025. * @param scene defines the hosting scene
  64026. * @returns the tiled box mesh
  64027. */
  64028. static CreateTiledBox(name: string, options: {
  64029. pattern?: number;
  64030. size?: number;
  64031. width?: number;
  64032. height?: number;
  64033. depth: number;
  64034. tileSize?: number;
  64035. tileWidth?: number;
  64036. tileHeight?: number;
  64037. faceUV?: Vector4[];
  64038. faceColors?: Color4[];
  64039. alignHorizontal?: number;
  64040. alignVertical?: number;
  64041. sideOrientation?: number;
  64042. updatable?: boolean;
  64043. }, scene?: Nullable<Scene>): Mesh;
  64044. /**
  64045. * Creates a sphere mesh
  64046. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64047. * * 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`)
  64048. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64049. * * 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
  64050. * * 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)
  64051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64052. * * 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
  64053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64054. * @param name defines the name of the mesh
  64055. * @param options defines the options used to create the mesh
  64056. * @param scene defines the hosting scene
  64057. * @returns the sphere mesh
  64058. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64059. */
  64060. static CreateSphere(name: string, options: {
  64061. segments?: number;
  64062. diameter?: number;
  64063. diameterX?: number;
  64064. diameterY?: number;
  64065. diameterZ?: number;
  64066. arc?: number;
  64067. slice?: number;
  64068. sideOrientation?: number;
  64069. frontUVs?: Vector4;
  64070. backUVs?: Vector4;
  64071. updatable?: boolean;
  64072. }, scene?: Nullable<Scene>): Mesh;
  64073. /**
  64074. * Creates a plane polygonal mesh. By default, this is a disc
  64075. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64076. * * 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
  64077. * * 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
  64078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64079. * * 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
  64080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64081. * @param name defines the name of the mesh
  64082. * @param options defines the options used to create the mesh
  64083. * @param scene defines the hosting scene
  64084. * @returns the plane polygonal mesh
  64085. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64086. */
  64087. static CreateDisc(name: string, options: {
  64088. radius?: number;
  64089. tessellation?: number;
  64090. arc?: number;
  64091. updatable?: boolean;
  64092. sideOrientation?: number;
  64093. frontUVs?: Vector4;
  64094. backUVs?: Vector4;
  64095. }, scene?: Nullable<Scene>): Mesh;
  64096. /**
  64097. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64098. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64099. * * 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`)
  64100. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64101. * * 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
  64102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64103. * * 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
  64104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64105. * @param name defines the name of the mesh
  64106. * @param options defines the options used to create the mesh
  64107. * @param scene defines the hosting scene
  64108. * @returns the icosahedron mesh
  64109. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64110. */
  64111. static CreateIcoSphere(name: string, options: {
  64112. radius?: number;
  64113. radiusX?: number;
  64114. radiusY?: number;
  64115. radiusZ?: number;
  64116. flat?: boolean;
  64117. subdivisions?: number;
  64118. sideOrientation?: number;
  64119. frontUVs?: Vector4;
  64120. backUVs?: Vector4;
  64121. updatable?: boolean;
  64122. }, scene?: Nullable<Scene>): Mesh;
  64123. /**
  64124. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64125. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64126. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64127. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64128. * * 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
  64129. * * 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
  64130. * * 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
  64131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64132. * * 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
  64133. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64134. * * 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
  64135. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64136. * * 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
  64137. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64139. * @param name defines the name of the mesh
  64140. * @param options defines the options used to create the mesh
  64141. * @param scene defines the hosting scene
  64142. * @returns the ribbon mesh
  64143. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64144. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64145. */
  64146. static CreateRibbon(name: string, options: {
  64147. pathArray: Vector3[][];
  64148. closeArray?: boolean;
  64149. closePath?: boolean;
  64150. offset?: number;
  64151. updatable?: boolean;
  64152. sideOrientation?: number;
  64153. frontUVs?: Vector4;
  64154. backUVs?: Vector4;
  64155. instance?: Mesh;
  64156. invertUV?: boolean;
  64157. uvs?: Vector2[];
  64158. colors?: Color4[];
  64159. }, scene?: Nullable<Scene>): Mesh;
  64160. /**
  64161. * Creates a cylinder or a cone mesh
  64162. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64163. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64164. * * 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.
  64165. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64166. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64167. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64168. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64169. * * 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).
  64170. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64171. * * 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).
  64172. * * 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
  64173. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64174. * * 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
  64175. * * 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.
  64176. * * If `enclose` is false, a ring surface is one element.
  64177. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64178. * * 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
  64179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64180. * * 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
  64181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64182. * @param name defines the name of the mesh
  64183. * @param options defines the options used to create the mesh
  64184. * @param scene defines the hosting scene
  64185. * @returns the cylinder mesh
  64186. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64187. */
  64188. static CreateCylinder(name: string, options: {
  64189. height?: number;
  64190. diameterTop?: number;
  64191. diameterBottom?: number;
  64192. diameter?: number;
  64193. tessellation?: number;
  64194. subdivisions?: number;
  64195. arc?: number;
  64196. faceColors?: Color4[];
  64197. faceUV?: Vector4[];
  64198. updatable?: boolean;
  64199. hasRings?: boolean;
  64200. enclose?: boolean;
  64201. cap?: number;
  64202. sideOrientation?: number;
  64203. frontUVs?: Vector4;
  64204. backUVs?: Vector4;
  64205. }, scene?: Nullable<Scene>): Mesh;
  64206. /**
  64207. * Creates a torus mesh
  64208. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64209. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64210. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64212. * * 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
  64213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64214. * @param name defines the name of the mesh
  64215. * @param options defines the options used to create the mesh
  64216. * @param scene defines the hosting scene
  64217. * @returns the torus mesh
  64218. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64219. */
  64220. static CreateTorus(name: string, options: {
  64221. diameter?: number;
  64222. thickness?: number;
  64223. tessellation?: number;
  64224. updatable?: boolean;
  64225. sideOrientation?: number;
  64226. frontUVs?: Vector4;
  64227. backUVs?: Vector4;
  64228. }, scene?: Nullable<Scene>): Mesh;
  64229. /**
  64230. * Creates a torus knot mesh
  64231. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64232. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64233. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64234. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64238. * @param name defines the name of the mesh
  64239. * @param options defines the options used to create the mesh
  64240. * @param scene defines the hosting scene
  64241. * @returns the torus knot mesh
  64242. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64243. */
  64244. static CreateTorusKnot(name: string, options: {
  64245. radius?: number;
  64246. tube?: number;
  64247. radialSegments?: number;
  64248. tubularSegments?: number;
  64249. p?: number;
  64250. q?: number;
  64251. updatable?: boolean;
  64252. sideOrientation?: number;
  64253. frontUVs?: Vector4;
  64254. backUVs?: Vector4;
  64255. }, scene?: Nullable<Scene>): Mesh;
  64256. /**
  64257. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64258. * * 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
  64259. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64260. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64261. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64262. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64263. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64264. * * 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
  64265. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64268. * @param name defines the name of the new line system
  64269. * @param options defines the options used to create the line system
  64270. * @param scene defines the hosting scene
  64271. * @returns a new line system mesh
  64272. */
  64273. static CreateLineSystem(name: string, options: {
  64274. lines: Vector3[][];
  64275. updatable?: boolean;
  64276. instance?: Nullable<LinesMesh>;
  64277. colors?: Nullable<Color4[][]>;
  64278. useVertexAlpha?: boolean;
  64279. }, scene: Nullable<Scene>): LinesMesh;
  64280. /**
  64281. * Creates a line mesh
  64282. * 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
  64283. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64284. * * The parameter `points` is an array successive Vector3
  64285. * * 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
  64286. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64287. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64288. * * When updating an instance, remember that only point positions can change, not the number of points
  64289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64291. * @param name defines the name of the new line system
  64292. * @param options defines the options used to create the line system
  64293. * @param scene defines the hosting scene
  64294. * @returns a new line mesh
  64295. */
  64296. static CreateLines(name: string, options: {
  64297. points: Vector3[];
  64298. updatable?: boolean;
  64299. instance?: Nullable<LinesMesh>;
  64300. colors?: Color4[];
  64301. useVertexAlpha?: boolean;
  64302. }, scene?: Nullable<Scene>): LinesMesh;
  64303. /**
  64304. * Creates a dashed line mesh
  64305. * * 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
  64306. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64307. * * The parameter `points` is an array successive Vector3
  64308. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64309. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64310. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64311. * * 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
  64312. * * When updating an instance, remember that only point positions can change, not the number of points
  64313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64314. * @param name defines the name of the mesh
  64315. * @param options defines the options used to create the mesh
  64316. * @param scene defines the hosting scene
  64317. * @returns the dashed line mesh
  64318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64319. */
  64320. static CreateDashedLines(name: string, options: {
  64321. points: Vector3[];
  64322. dashSize?: number;
  64323. gapSize?: number;
  64324. dashNb?: number;
  64325. updatable?: boolean;
  64326. instance?: LinesMesh;
  64327. }, scene?: Nullable<Scene>): LinesMesh;
  64328. /**
  64329. * 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.
  64330. * * 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.
  64331. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64332. * * 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.
  64333. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64334. * * 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
  64335. * * 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
  64336. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64338. * * 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
  64339. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64341. * @param name defines the name of the mesh
  64342. * @param options defines the options used to create the mesh
  64343. * @param scene defines the hosting scene
  64344. * @returns the extruded shape mesh
  64345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64347. */
  64348. static ExtrudeShape(name: string, options: {
  64349. shape: Vector3[];
  64350. path: Vector3[];
  64351. scale?: number;
  64352. rotation?: number;
  64353. cap?: number;
  64354. updatable?: boolean;
  64355. sideOrientation?: number;
  64356. frontUVs?: Vector4;
  64357. backUVs?: Vector4;
  64358. instance?: Mesh;
  64359. invertUV?: boolean;
  64360. }, scene?: Nullable<Scene>): Mesh;
  64361. /**
  64362. * Creates an custom extruded shape mesh.
  64363. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64364. * * 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.
  64365. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64366. * * 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
  64367. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64368. * * 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
  64369. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64370. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64371. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64372. * * 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
  64373. * * 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
  64374. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64376. * * 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
  64377. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64379. * @param name defines the name of the mesh
  64380. * @param options defines the options used to create the mesh
  64381. * @param scene defines the hosting scene
  64382. * @returns the custom extruded shape mesh
  64383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64384. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64386. */
  64387. static ExtrudeShapeCustom(name: string, options: {
  64388. shape: Vector3[];
  64389. path: Vector3[];
  64390. scaleFunction?: any;
  64391. rotationFunction?: any;
  64392. ribbonCloseArray?: boolean;
  64393. ribbonClosePath?: boolean;
  64394. cap?: number;
  64395. updatable?: boolean;
  64396. sideOrientation?: number;
  64397. frontUVs?: Vector4;
  64398. backUVs?: Vector4;
  64399. instance?: Mesh;
  64400. invertUV?: boolean;
  64401. }, scene?: Nullable<Scene>): Mesh;
  64402. /**
  64403. * Creates lathe mesh.
  64404. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64405. * * 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
  64406. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64407. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64408. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64409. * * 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
  64410. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64411. * * 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
  64412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64413. * * 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
  64414. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64416. * @param name defines the name of the mesh
  64417. * @param options defines the options used to create the mesh
  64418. * @param scene defines the hosting scene
  64419. * @returns the lathe mesh
  64420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64421. */
  64422. static CreateLathe(name: string, options: {
  64423. shape: Vector3[];
  64424. radius?: number;
  64425. tessellation?: number;
  64426. clip?: number;
  64427. arc?: number;
  64428. closed?: boolean;
  64429. updatable?: boolean;
  64430. sideOrientation?: number;
  64431. frontUVs?: Vector4;
  64432. backUVs?: Vector4;
  64433. cap?: number;
  64434. invertUV?: boolean;
  64435. }, scene?: Nullable<Scene>): Mesh;
  64436. /**
  64437. * Creates a tiled plane mesh
  64438. * * You can set a limited pattern arrangement with the tiles
  64439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64440. * * 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
  64441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64442. * @param name defines the name of the mesh
  64443. * @param options defines the options used to create the mesh
  64444. * @param scene defines the hosting scene
  64445. * @returns the plane mesh
  64446. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64447. */
  64448. static CreateTiledPlane(name: string, options: {
  64449. pattern?: number;
  64450. tileSize?: number;
  64451. tileWidth?: number;
  64452. tileHeight?: number;
  64453. size?: number;
  64454. width?: number;
  64455. height?: number;
  64456. alignHorizontal?: number;
  64457. alignVertical?: number;
  64458. sideOrientation?: number;
  64459. frontUVs?: Vector4;
  64460. backUVs?: Vector4;
  64461. updatable?: boolean;
  64462. }, scene?: Nullable<Scene>): Mesh;
  64463. /**
  64464. * Creates a plane mesh
  64465. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64466. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64467. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64469. * * 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
  64470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64471. * @param name defines the name of the mesh
  64472. * @param options defines the options used to create the mesh
  64473. * @param scene defines the hosting scene
  64474. * @returns the plane mesh
  64475. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64476. */
  64477. static CreatePlane(name: string, options: {
  64478. size?: number;
  64479. width?: number;
  64480. height?: number;
  64481. sideOrientation?: number;
  64482. frontUVs?: Vector4;
  64483. backUVs?: Vector4;
  64484. updatable?: boolean;
  64485. sourcePlane?: Plane;
  64486. }, scene?: Nullable<Scene>): Mesh;
  64487. /**
  64488. * Creates a ground mesh
  64489. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64490. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64492. * @param name defines the name of the mesh
  64493. * @param options defines the options used to create the mesh
  64494. * @param scene defines the hosting scene
  64495. * @returns the ground mesh
  64496. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64497. */
  64498. static CreateGround(name: string, options: {
  64499. width?: number;
  64500. height?: number;
  64501. subdivisions?: number;
  64502. subdivisionsX?: number;
  64503. subdivisionsY?: number;
  64504. updatable?: boolean;
  64505. }, scene?: Nullable<Scene>): Mesh;
  64506. /**
  64507. * Creates a tiled ground mesh
  64508. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64509. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64510. * * 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
  64511. * * 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
  64512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64513. * @param name defines the name of the mesh
  64514. * @param options defines the options used to create the mesh
  64515. * @param scene defines the hosting scene
  64516. * @returns the tiled ground mesh
  64517. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64518. */
  64519. static CreateTiledGround(name: string, options: {
  64520. xmin: number;
  64521. zmin: number;
  64522. xmax: number;
  64523. zmax: number;
  64524. subdivisions?: {
  64525. w: number;
  64526. h: number;
  64527. };
  64528. precision?: {
  64529. w: number;
  64530. h: number;
  64531. };
  64532. updatable?: boolean;
  64533. }, scene?: Nullable<Scene>): Mesh;
  64534. /**
  64535. * Creates a ground mesh from a height map
  64536. * * The parameter `url` sets the URL of the height map image resource.
  64537. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64538. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64539. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64540. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64541. * * 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.
  64542. * * 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).
  64543. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64545. * @param name defines the name of the mesh
  64546. * @param url defines the url to the height map
  64547. * @param options defines the options used to create the mesh
  64548. * @param scene defines the hosting scene
  64549. * @returns the ground mesh
  64550. * @see https://doc.babylonjs.com/babylon101/height_map
  64551. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64552. */
  64553. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64554. width?: number;
  64555. height?: number;
  64556. subdivisions?: number;
  64557. minHeight?: number;
  64558. maxHeight?: number;
  64559. colorFilter?: Color3;
  64560. alphaFilter?: number;
  64561. updatable?: boolean;
  64562. onReady?: (mesh: GroundMesh) => void;
  64563. }, scene?: Nullable<Scene>): GroundMesh;
  64564. /**
  64565. * Creates a polygon mesh
  64566. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64567. * * 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
  64568. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64570. * * 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)
  64571. * * Remember you can only change the shape positions, not their number when updating a polygon
  64572. * @param name defines the name of the mesh
  64573. * @param options defines the options used to create the mesh
  64574. * @param scene defines the hosting scene
  64575. * @param earcutInjection can be used to inject your own earcut reference
  64576. * @returns the polygon mesh
  64577. */
  64578. static CreatePolygon(name: string, options: {
  64579. shape: Vector3[];
  64580. holes?: Vector3[][];
  64581. depth?: number;
  64582. faceUV?: Vector4[];
  64583. faceColors?: Color4[];
  64584. updatable?: boolean;
  64585. sideOrientation?: number;
  64586. frontUVs?: Vector4;
  64587. backUVs?: Vector4;
  64588. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64589. /**
  64590. * Creates an extruded polygon mesh, with depth in the Y direction.
  64591. * * 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)
  64592. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64593. * @param name defines the name of the mesh
  64594. * @param options defines the options used to create the mesh
  64595. * @param scene defines the hosting scene
  64596. * @param earcutInjection can be used to inject your own earcut reference
  64597. * @returns the polygon mesh
  64598. */
  64599. static ExtrudePolygon(name: string, options: {
  64600. shape: Vector3[];
  64601. holes?: Vector3[][];
  64602. depth?: number;
  64603. faceUV?: Vector4[];
  64604. faceColors?: Color4[];
  64605. updatable?: boolean;
  64606. sideOrientation?: number;
  64607. frontUVs?: Vector4;
  64608. backUVs?: Vector4;
  64609. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64610. /**
  64611. * Creates a tube mesh.
  64612. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64613. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64614. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64615. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64616. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64617. * * 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)
  64618. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64619. * * 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
  64620. * * 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
  64621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64622. * * 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
  64623. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64625. * @param name defines the name of the mesh
  64626. * @param options defines the options used to create the mesh
  64627. * @param scene defines the hosting scene
  64628. * @returns the tube mesh
  64629. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64630. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64631. */
  64632. static CreateTube(name: string, options: {
  64633. path: Vector3[];
  64634. radius?: number;
  64635. tessellation?: number;
  64636. radiusFunction?: {
  64637. (i: number, distance: number): number;
  64638. };
  64639. cap?: number;
  64640. arc?: number;
  64641. updatable?: boolean;
  64642. sideOrientation?: number;
  64643. frontUVs?: Vector4;
  64644. backUVs?: Vector4;
  64645. instance?: Mesh;
  64646. invertUV?: boolean;
  64647. }, scene?: Nullable<Scene>): Mesh;
  64648. /**
  64649. * Creates a polyhedron mesh
  64650. * * 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
  64651. * * The parameter `size` (positive float, default 1) sets the polygon size
  64652. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64653. * * 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`
  64654. * * 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
  64655. * * 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)`)
  64656. * * 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
  64657. * * 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
  64658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64659. * * 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
  64660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64661. * @param name defines the name of the mesh
  64662. * @param options defines the options used to create the mesh
  64663. * @param scene defines the hosting scene
  64664. * @returns the polyhedron mesh
  64665. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64666. */
  64667. static CreatePolyhedron(name: string, options: {
  64668. type?: number;
  64669. size?: number;
  64670. sizeX?: number;
  64671. sizeY?: number;
  64672. sizeZ?: number;
  64673. custom?: any;
  64674. faceUV?: Vector4[];
  64675. faceColors?: Color4[];
  64676. flat?: boolean;
  64677. updatable?: boolean;
  64678. sideOrientation?: number;
  64679. frontUVs?: Vector4;
  64680. backUVs?: Vector4;
  64681. }, scene?: Nullable<Scene>): Mesh;
  64682. /**
  64683. * Creates a decal mesh.
  64684. * 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
  64685. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64686. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64687. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64688. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64689. * @param name defines the name of the mesh
  64690. * @param sourceMesh defines the mesh where the decal must be applied
  64691. * @param options defines the options used to create the mesh
  64692. * @param scene defines the hosting scene
  64693. * @returns the decal mesh
  64694. * @see https://doc.babylonjs.com/how_to/decals
  64695. */
  64696. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64697. position?: Vector3;
  64698. normal?: Vector3;
  64699. size?: Vector3;
  64700. angle?: number;
  64701. }): Mesh;
  64702. }
  64703. }
  64704. declare module BABYLON {
  64705. /**
  64706. * A simplifier interface for future simplification implementations
  64707. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64708. */
  64709. export interface ISimplifier {
  64710. /**
  64711. * Simplification of a given mesh according to the given settings.
  64712. * Since this requires computation, it is assumed that the function runs async.
  64713. * @param settings The settings of the simplification, including quality and distance
  64714. * @param successCallback A callback that will be called after the mesh was simplified.
  64715. * @param errorCallback in case of an error, this callback will be called. optional.
  64716. */
  64717. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64718. }
  64719. /**
  64720. * Expected simplification settings.
  64721. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64722. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64723. */
  64724. export interface ISimplificationSettings {
  64725. /**
  64726. * Gets or sets the expected quality
  64727. */
  64728. quality: number;
  64729. /**
  64730. * Gets or sets the distance when this optimized version should be used
  64731. */
  64732. distance: number;
  64733. /**
  64734. * Gets an already optimized mesh
  64735. */
  64736. optimizeMesh?: boolean;
  64737. }
  64738. /**
  64739. * Class used to specify simplification options
  64740. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64741. */
  64742. export class SimplificationSettings implements ISimplificationSettings {
  64743. /** expected quality */
  64744. quality: number;
  64745. /** distance when this optimized version should be used */
  64746. distance: number;
  64747. /** already optimized mesh */
  64748. optimizeMesh?: boolean | undefined;
  64749. /**
  64750. * Creates a SimplificationSettings
  64751. * @param quality expected quality
  64752. * @param distance distance when this optimized version should be used
  64753. * @param optimizeMesh already optimized mesh
  64754. */
  64755. constructor(
  64756. /** expected quality */
  64757. quality: number,
  64758. /** distance when this optimized version should be used */
  64759. distance: number,
  64760. /** already optimized mesh */
  64761. optimizeMesh?: boolean | undefined);
  64762. }
  64763. /**
  64764. * Interface used to define a simplification task
  64765. */
  64766. export interface ISimplificationTask {
  64767. /**
  64768. * Array of settings
  64769. */
  64770. settings: Array<ISimplificationSettings>;
  64771. /**
  64772. * Simplification type
  64773. */
  64774. simplificationType: SimplificationType;
  64775. /**
  64776. * Mesh to simplify
  64777. */
  64778. mesh: Mesh;
  64779. /**
  64780. * Callback called on success
  64781. */
  64782. successCallback?: () => void;
  64783. /**
  64784. * Defines if parallel processing can be used
  64785. */
  64786. parallelProcessing: boolean;
  64787. }
  64788. /**
  64789. * Queue used to order the simplification tasks
  64790. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64791. */
  64792. export class SimplificationQueue {
  64793. private _simplificationArray;
  64794. /**
  64795. * Gets a boolean indicating that the process is still running
  64796. */
  64797. running: boolean;
  64798. /**
  64799. * Creates a new queue
  64800. */
  64801. constructor();
  64802. /**
  64803. * Adds a new simplification task
  64804. * @param task defines a task to add
  64805. */
  64806. addTask(task: ISimplificationTask): void;
  64807. /**
  64808. * Execute next task
  64809. */
  64810. executeNext(): void;
  64811. /**
  64812. * Execute a simplification task
  64813. * @param task defines the task to run
  64814. */
  64815. runSimplification(task: ISimplificationTask): void;
  64816. private getSimplifier;
  64817. }
  64818. /**
  64819. * The implemented types of simplification
  64820. * At the moment only Quadratic Error Decimation is implemented
  64821. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64822. */
  64823. export enum SimplificationType {
  64824. /** Quadratic error decimation */
  64825. QUADRATIC = 0
  64826. }
  64827. /**
  64828. * An implementation of the Quadratic Error simplification algorithm.
  64829. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  64830. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  64831. * @author RaananW
  64832. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64833. */
  64834. export class QuadraticErrorSimplification implements ISimplifier {
  64835. private _mesh;
  64836. private triangles;
  64837. private vertices;
  64838. private references;
  64839. private _reconstructedMesh;
  64840. /** Gets or sets the number pf sync interations */
  64841. syncIterations: number;
  64842. /** Gets or sets the aggressiveness of the simplifier */
  64843. aggressiveness: number;
  64844. /** Gets or sets the number of allowed iterations for decimation */
  64845. decimationIterations: number;
  64846. /** Gets or sets the espilon to use for bounding box computation */
  64847. boundingBoxEpsilon: number;
  64848. /**
  64849. * Creates a new QuadraticErrorSimplification
  64850. * @param _mesh defines the target mesh
  64851. */
  64852. constructor(_mesh: Mesh);
  64853. /**
  64854. * Simplification of a given mesh according to the given settings.
  64855. * Since this requires computation, it is assumed that the function runs async.
  64856. * @param settings The settings of the simplification, including quality and distance
  64857. * @param successCallback A callback that will be called after the mesh was simplified.
  64858. */
  64859. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  64860. private runDecimation;
  64861. private initWithMesh;
  64862. private init;
  64863. private reconstructMesh;
  64864. private initDecimatedMesh;
  64865. private isFlipped;
  64866. private updateTriangles;
  64867. private identifyBorder;
  64868. private updateMesh;
  64869. private vertexError;
  64870. private calculateError;
  64871. }
  64872. }
  64873. declare module BABYLON {
  64874. interface Scene {
  64875. /** @hidden (Backing field) */
  64876. _simplificationQueue: SimplificationQueue;
  64877. /**
  64878. * Gets or sets the simplification queue attached to the scene
  64879. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64880. */
  64881. simplificationQueue: SimplificationQueue;
  64882. }
  64883. interface Mesh {
  64884. /**
  64885. * Simplify the mesh according to the given array of settings.
  64886. * Function will return immediately and will simplify async
  64887. * @param settings a collection of simplification settings
  64888. * @param parallelProcessing should all levels calculate parallel or one after the other
  64889. * @param simplificationType the type of simplification to run
  64890. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64891. * @returns the current mesh
  64892. */
  64893. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64894. }
  64895. /**
  64896. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64897. * created in a scene
  64898. */
  64899. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64900. /**
  64901. * The component name helpfull to identify the component in the list of scene components.
  64902. */
  64903. readonly name: string;
  64904. /**
  64905. * The scene the component belongs to.
  64906. */
  64907. scene: Scene;
  64908. /**
  64909. * Creates a new instance of the component for the given scene
  64910. * @param scene Defines the scene to register the component in
  64911. */
  64912. constructor(scene: Scene);
  64913. /**
  64914. * Registers the component in a given scene
  64915. */
  64916. register(): void;
  64917. /**
  64918. * Rebuilds the elements related to this component in case of
  64919. * context lost for instance.
  64920. */
  64921. rebuild(): void;
  64922. /**
  64923. * Disposes the component and the associated ressources
  64924. */
  64925. dispose(): void;
  64926. private _beforeCameraUpdate;
  64927. }
  64928. }
  64929. declare module BABYLON {
  64930. interface Mesh {
  64931. /**
  64932. * Creates a new thin instance
  64933. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  64934. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  64935. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  64936. */
  64937. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  64938. /**
  64939. * Adds the transformation (matrix) of the current mesh as a thin instance
  64940. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  64941. * @returns the thin instance index number
  64942. */
  64943. thinInstanceAddSelf(refresh: boolean): number;
  64944. /**
  64945. * Registers a custom attribute to be used with thin instances
  64946. * @param kind name of the attribute
  64947. * @param stride size in floats of the attribute
  64948. */
  64949. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  64950. /**
  64951. * Sets the matrix of a thin instance
  64952. * @param index index of the thin instance
  64953. * @param matrix matrix to set
  64954. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  64955. */
  64956. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  64957. /**
  64958. * Sets the value of a custom attribute for a thin instance
  64959. * @param kind name of the attribute
  64960. * @param index index of the thin instance
  64961. * @param value value to set
  64962. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  64963. */
  64964. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  64965. /**
  64966. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  64967. */
  64968. thinInstanceCount: number;
  64969. /**
  64970. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  64971. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  64972. * @param buffer buffer to set
  64973. * @param stride size in floats of each value of the buffer
  64974. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  64975. */
  64976. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  64977. /**
  64978. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  64979. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  64980. */
  64981. thinInstanceBufferUpdated(kind: string): void;
  64982. /**
  64983. * Refreshes the bounding info, taking into account all the thin instances defined
  64984. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  64985. */
  64986. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  64987. /** @hidden */
  64988. _thinInstanceInitializeUserStorage(): void;
  64989. /** @hidden */
  64990. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  64991. /** @hidden */
  64992. _userThinInstanceBuffersStorage: {
  64993. data: {
  64994. [key: string]: Float32Array;
  64995. };
  64996. sizes: {
  64997. [key: string]: number;
  64998. };
  64999. vertexBuffers: {
  65000. [key: string]: Nullable<VertexBuffer>;
  65001. };
  65002. strides: {
  65003. [key: string]: number;
  65004. };
  65005. };
  65006. }
  65007. }
  65008. declare module BABYLON {
  65009. /**
  65010. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65011. */
  65012. export interface INavigationEnginePlugin {
  65013. /**
  65014. * plugin name
  65015. */
  65016. name: string;
  65017. /**
  65018. * Creates a navigation mesh
  65019. * @param meshes array of all the geometry used to compute the navigatio mesh
  65020. * @param parameters bunch of parameters used to filter geometry
  65021. */
  65022. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65023. /**
  65024. * Create a navigation mesh debug mesh
  65025. * @param scene is where the mesh will be added
  65026. * @returns debug display mesh
  65027. */
  65028. createDebugNavMesh(scene: Scene): Mesh;
  65029. /**
  65030. * Get a navigation mesh constrained position, closest to the parameter position
  65031. * @param position world position
  65032. * @returns the closest point to position constrained by the navigation mesh
  65033. */
  65034. getClosestPoint(position: Vector3): Vector3;
  65035. /**
  65036. * Get a navigation mesh constrained position, closest to the parameter position
  65037. * @param position world position
  65038. * @param result output the closest point to position constrained by the navigation mesh
  65039. */
  65040. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65041. /**
  65042. * Get a navigation mesh constrained position, within a particular radius
  65043. * @param position world position
  65044. * @param maxRadius the maximum distance to the constrained world position
  65045. * @returns the closest point to position constrained by the navigation mesh
  65046. */
  65047. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65048. /**
  65049. * Get a navigation mesh constrained position, within a particular radius
  65050. * @param position world position
  65051. * @param maxRadius the maximum distance to the constrained world position
  65052. * @param result output the closest point to position constrained by the navigation mesh
  65053. */
  65054. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65055. /**
  65056. * Compute the final position from a segment made of destination-position
  65057. * @param position world position
  65058. * @param destination world position
  65059. * @returns the resulting point along the navmesh
  65060. */
  65061. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65062. /**
  65063. * Compute the final position from a segment made of destination-position
  65064. * @param position world position
  65065. * @param destination world position
  65066. * @param result output the resulting point along the navmesh
  65067. */
  65068. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65069. /**
  65070. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65071. * @param start world position
  65072. * @param end world position
  65073. * @returns array containing world position composing the path
  65074. */
  65075. computePath(start: Vector3, end: Vector3): Vector3[];
  65076. /**
  65077. * If this plugin is supported
  65078. * @returns true if plugin is supported
  65079. */
  65080. isSupported(): boolean;
  65081. /**
  65082. * Create a new Crowd so you can add agents
  65083. * @param maxAgents the maximum agent count in the crowd
  65084. * @param maxAgentRadius the maximum radius an agent can have
  65085. * @param scene to attach the crowd to
  65086. * @returns the crowd you can add agents to
  65087. */
  65088. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65089. /**
  65090. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65091. * The queries will try to find a solution within those bounds
  65092. * default is (1,1,1)
  65093. * @param extent x,y,z value that define the extent around the queries point of reference
  65094. */
  65095. setDefaultQueryExtent(extent: Vector3): void;
  65096. /**
  65097. * Get the Bounding box extent specified by setDefaultQueryExtent
  65098. * @returns the box extent values
  65099. */
  65100. getDefaultQueryExtent(): Vector3;
  65101. /**
  65102. * build the navmesh from a previously saved state using getNavmeshData
  65103. * @param data the Uint8Array returned by getNavmeshData
  65104. */
  65105. buildFromNavmeshData(data: Uint8Array): void;
  65106. /**
  65107. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65108. * @returns data the Uint8Array that can be saved and reused
  65109. */
  65110. getNavmeshData(): Uint8Array;
  65111. /**
  65112. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65113. * @param result output the box extent values
  65114. */
  65115. getDefaultQueryExtentToRef(result: Vector3): void;
  65116. /**
  65117. * Release all resources
  65118. */
  65119. dispose(): void;
  65120. }
  65121. /**
  65122. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65123. */
  65124. export interface ICrowd {
  65125. /**
  65126. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65127. * You can attach anything to that node. The node position is updated in the scene update tick.
  65128. * @param pos world position that will be constrained by the navigation mesh
  65129. * @param parameters agent parameters
  65130. * @param transform hooked to the agent that will be update by the scene
  65131. * @returns agent index
  65132. */
  65133. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65134. /**
  65135. * Returns the agent position in world space
  65136. * @param index agent index returned by addAgent
  65137. * @returns world space position
  65138. */
  65139. getAgentPosition(index: number): Vector3;
  65140. /**
  65141. * Gets the agent position result in world space
  65142. * @param index agent index returned by addAgent
  65143. * @param result output world space position
  65144. */
  65145. getAgentPositionToRef(index: number, result: Vector3): void;
  65146. /**
  65147. * Gets the agent velocity in world space
  65148. * @param index agent index returned by addAgent
  65149. * @returns world space velocity
  65150. */
  65151. getAgentVelocity(index: number): Vector3;
  65152. /**
  65153. * Gets the agent velocity result in world space
  65154. * @param index agent index returned by addAgent
  65155. * @param result output world space velocity
  65156. */
  65157. getAgentVelocityToRef(index: number, result: Vector3): void;
  65158. /**
  65159. * remove a particular agent previously created
  65160. * @param index agent index returned by addAgent
  65161. */
  65162. removeAgent(index: number): void;
  65163. /**
  65164. * get the list of all agents attached to this crowd
  65165. * @returns list of agent indices
  65166. */
  65167. getAgents(): number[];
  65168. /**
  65169. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65170. * @param deltaTime in seconds
  65171. */
  65172. update(deltaTime: number): void;
  65173. /**
  65174. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65175. * @param index agent index returned by addAgent
  65176. * @param destination targeted world position
  65177. */
  65178. agentGoto(index: number, destination: Vector3): void;
  65179. /**
  65180. * Teleport the agent to a new position
  65181. * @param index agent index returned by addAgent
  65182. * @param destination targeted world position
  65183. */
  65184. agentTeleport(index: number, destination: Vector3): void;
  65185. /**
  65186. * Update agent parameters
  65187. * @param index agent index returned by addAgent
  65188. * @param parameters agent parameters
  65189. */
  65190. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65191. /**
  65192. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65193. * The queries will try to find a solution within those bounds
  65194. * default is (1,1,1)
  65195. * @param extent x,y,z value that define the extent around the queries point of reference
  65196. */
  65197. setDefaultQueryExtent(extent: Vector3): void;
  65198. /**
  65199. * Get the Bounding box extent specified by setDefaultQueryExtent
  65200. * @returns the box extent values
  65201. */
  65202. getDefaultQueryExtent(): Vector3;
  65203. /**
  65204. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65205. * @param result output the box extent values
  65206. */
  65207. getDefaultQueryExtentToRef(result: Vector3): void;
  65208. /**
  65209. * Release all resources
  65210. */
  65211. dispose(): void;
  65212. }
  65213. /**
  65214. * Configures an agent
  65215. */
  65216. export interface IAgentParameters {
  65217. /**
  65218. * Agent radius. [Limit: >= 0]
  65219. */
  65220. radius: number;
  65221. /**
  65222. * Agent height. [Limit: > 0]
  65223. */
  65224. height: number;
  65225. /**
  65226. * Maximum allowed acceleration. [Limit: >= 0]
  65227. */
  65228. maxAcceleration: number;
  65229. /**
  65230. * Maximum allowed speed. [Limit: >= 0]
  65231. */
  65232. maxSpeed: number;
  65233. /**
  65234. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65235. */
  65236. collisionQueryRange: number;
  65237. /**
  65238. * The path visibility optimization range. [Limit: > 0]
  65239. */
  65240. pathOptimizationRange: number;
  65241. /**
  65242. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65243. */
  65244. separationWeight: number;
  65245. }
  65246. /**
  65247. * Configures the navigation mesh creation
  65248. */
  65249. export interface INavMeshParameters {
  65250. /**
  65251. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65252. */
  65253. cs: number;
  65254. /**
  65255. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65256. */
  65257. ch: number;
  65258. /**
  65259. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65260. */
  65261. walkableSlopeAngle: number;
  65262. /**
  65263. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65264. * be considered walkable. [Limit: >= 3] [Units: vx]
  65265. */
  65266. walkableHeight: number;
  65267. /**
  65268. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65269. */
  65270. walkableClimb: number;
  65271. /**
  65272. * The distance to erode/shrink the walkable area of the heightfield away from
  65273. * obstructions. [Limit: >=0] [Units: vx]
  65274. */
  65275. walkableRadius: number;
  65276. /**
  65277. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65278. */
  65279. maxEdgeLen: number;
  65280. /**
  65281. * The maximum distance a simplfied contour's border edges should deviate
  65282. * the original raw contour. [Limit: >=0] [Units: vx]
  65283. */
  65284. maxSimplificationError: number;
  65285. /**
  65286. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65287. */
  65288. minRegionArea: number;
  65289. /**
  65290. * Any regions with a span count smaller than this value will, if possible,
  65291. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65292. */
  65293. mergeRegionArea: number;
  65294. /**
  65295. * The maximum number of vertices allowed for polygons generated during the
  65296. * contour to polygon conversion process. [Limit: >= 3]
  65297. */
  65298. maxVertsPerPoly: number;
  65299. /**
  65300. * Sets the sampling distance to use when generating the detail mesh.
  65301. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65302. */
  65303. detailSampleDist: number;
  65304. /**
  65305. * The maximum distance the detail mesh surface should deviate from heightfield
  65306. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65307. */
  65308. detailSampleMaxError: number;
  65309. }
  65310. }
  65311. declare module BABYLON {
  65312. /**
  65313. * RecastJS navigation plugin
  65314. */
  65315. export class RecastJSPlugin implements INavigationEnginePlugin {
  65316. /**
  65317. * Reference to the Recast library
  65318. */
  65319. bjsRECAST: any;
  65320. /**
  65321. * plugin name
  65322. */
  65323. name: string;
  65324. /**
  65325. * the first navmesh created. We might extend this to support multiple navmeshes
  65326. */
  65327. navMesh: any;
  65328. /**
  65329. * Initializes the recastJS plugin
  65330. * @param recastInjection can be used to inject your own recast reference
  65331. */
  65332. constructor(recastInjection?: any);
  65333. /**
  65334. * Creates a navigation mesh
  65335. * @param meshes array of all the geometry used to compute the navigatio mesh
  65336. * @param parameters bunch of parameters used to filter geometry
  65337. */
  65338. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65339. /**
  65340. * Create a navigation mesh debug mesh
  65341. * @param scene is where the mesh will be added
  65342. * @returns debug display mesh
  65343. */
  65344. createDebugNavMesh(scene: Scene): Mesh;
  65345. /**
  65346. * Get a navigation mesh constrained position, closest to the parameter position
  65347. * @param position world position
  65348. * @returns the closest point to position constrained by the navigation mesh
  65349. */
  65350. getClosestPoint(position: Vector3): Vector3;
  65351. /**
  65352. * Get a navigation mesh constrained position, closest to the parameter position
  65353. * @param position world position
  65354. * @param result output the closest point to position constrained by the navigation mesh
  65355. */
  65356. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65357. /**
  65358. * Get a navigation mesh constrained position, within a particular radius
  65359. * @param position world position
  65360. * @param maxRadius the maximum distance to the constrained world position
  65361. * @returns the closest point to position constrained by the navigation mesh
  65362. */
  65363. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65364. /**
  65365. * Get a navigation mesh constrained position, within a particular radius
  65366. * @param position world position
  65367. * @param maxRadius the maximum distance to the constrained world position
  65368. * @param result output the closest point to position constrained by the navigation mesh
  65369. */
  65370. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65371. /**
  65372. * Compute the final position from a segment made of destination-position
  65373. * @param position world position
  65374. * @param destination world position
  65375. * @returns the resulting point along the navmesh
  65376. */
  65377. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65378. /**
  65379. * Compute the final position from a segment made of destination-position
  65380. * @param position world position
  65381. * @param destination world position
  65382. * @param result output the resulting point along the navmesh
  65383. */
  65384. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65385. /**
  65386. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65387. * @param start world position
  65388. * @param end world position
  65389. * @returns array containing world position composing the path
  65390. */
  65391. computePath(start: Vector3, end: Vector3): Vector3[];
  65392. /**
  65393. * Create a new Crowd so you can add agents
  65394. * @param maxAgents the maximum agent count in the crowd
  65395. * @param maxAgentRadius the maximum radius an agent can have
  65396. * @param scene to attach the crowd to
  65397. * @returns the crowd you can add agents to
  65398. */
  65399. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65400. /**
  65401. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65402. * The queries will try to find a solution within those bounds
  65403. * default is (1,1,1)
  65404. * @param extent x,y,z value that define the extent around the queries point of reference
  65405. */
  65406. setDefaultQueryExtent(extent: Vector3): void;
  65407. /**
  65408. * Get the Bounding box extent specified by setDefaultQueryExtent
  65409. * @returns the box extent values
  65410. */
  65411. getDefaultQueryExtent(): Vector3;
  65412. /**
  65413. * build the navmesh from a previously saved state using getNavmeshData
  65414. * @param data the Uint8Array returned by getNavmeshData
  65415. */
  65416. buildFromNavmeshData(data: Uint8Array): void;
  65417. /**
  65418. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65419. * @returns data the Uint8Array that can be saved and reused
  65420. */
  65421. getNavmeshData(): Uint8Array;
  65422. /**
  65423. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65424. * @param result output the box extent values
  65425. */
  65426. getDefaultQueryExtentToRef(result: Vector3): void;
  65427. /**
  65428. * Disposes
  65429. */
  65430. dispose(): void;
  65431. /**
  65432. * If this plugin is supported
  65433. * @returns true if plugin is supported
  65434. */
  65435. isSupported(): boolean;
  65436. }
  65437. /**
  65438. * Recast detour crowd implementation
  65439. */
  65440. export class RecastJSCrowd implements ICrowd {
  65441. /**
  65442. * Recast/detour plugin
  65443. */
  65444. bjsRECASTPlugin: RecastJSPlugin;
  65445. /**
  65446. * Link to the detour crowd
  65447. */
  65448. recastCrowd: any;
  65449. /**
  65450. * One transform per agent
  65451. */
  65452. transforms: TransformNode[];
  65453. /**
  65454. * All agents created
  65455. */
  65456. agents: number[];
  65457. /**
  65458. * Link to the scene is kept to unregister the crowd from the scene
  65459. */
  65460. private _scene;
  65461. /**
  65462. * Observer for crowd updates
  65463. */
  65464. private _onBeforeAnimationsObserver;
  65465. /**
  65466. * Constructor
  65467. * @param plugin recastJS plugin
  65468. * @param maxAgents the maximum agent count in the crowd
  65469. * @param maxAgentRadius the maximum radius an agent can have
  65470. * @param scene to attach the crowd to
  65471. * @returns the crowd you can add agents to
  65472. */
  65473. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65474. /**
  65475. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65476. * You can attach anything to that node. The node position is updated in the scene update tick.
  65477. * @param pos world position that will be constrained by the navigation mesh
  65478. * @param parameters agent parameters
  65479. * @param transform hooked to the agent that will be update by the scene
  65480. * @returns agent index
  65481. */
  65482. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65483. /**
  65484. * Returns the agent position in world space
  65485. * @param index agent index returned by addAgent
  65486. * @returns world space position
  65487. */
  65488. getAgentPosition(index: number): Vector3;
  65489. /**
  65490. * Returns the agent position result in world space
  65491. * @param index agent index returned by addAgent
  65492. * @param result output world space position
  65493. */
  65494. getAgentPositionToRef(index: number, result: Vector3): void;
  65495. /**
  65496. * Returns the agent velocity in world space
  65497. * @param index agent index returned by addAgent
  65498. * @returns world space velocity
  65499. */
  65500. getAgentVelocity(index: number): Vector3;
  65501. /**
  65502. * Returns the agent velocity result in world space
  65503. * @param index agent index returned by addAgent
  65504. * @param result output world space velocity
  65505. */
  65506. getAgentVelocityToRef(index: number, result: Vector3): void;
  65507. /**
  65508. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65509. * @param index agent index returned by addAgent
  65510. * @param destination targeted world position
  65511. */
  65512. agentGoto(index: number, destination: Vector3): void;
  65513. /**
  65514. * Teleport the agent to a new position
  65515. * @param index agent index returned by addAgent
  65516. * @param destination targeted world position
  65517. */
  65518. agentTeleport(index: number, destination: Vector3): void;
  65519. /**
  65520. * Update agent parameters
  65521. * @param index agent index returned by addAgent
  65522. * @param parameters agent parameters
  65523. */
  65524. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65525. /**
  65526. * remove a particular agent previously created
  65527. * @param index agent index returned by addAgent
  65528. */
  65529. removeAgent(index: number): void;
  65530. /**
  65531. * get the list of all agents attached to this crowd
  65532. * @returns list of agent indices
  65533. */
  65534. getAgents(): number[];
  65535. /**
  65536. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65537. * @param deltaTime in seconds
  65538. */
  65539. update(deltaTime: number): void;
  65540. /**
  65541. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65542. * The queries will try to find a solution within those bounds
  65543. * default is (1,1,1)
  65544. * @param extent x,y,z value that define the extent around the queries point of reference
  65545. */
  65546. setDefaultQueryExtent(extent: Vector3): void;
  65547. /**
  65548. * Get the Bounding box extent specified by setDefaultQueryExtent
  65549. * @returns the box extent values
  65550. */
  65551. getDefaultQueryExtent(): Vector3;
  65552. /**
  65553. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65554. * @param result output the box extent values
  65555. */
  65556. getDefaultQueryExtentToRef(result: Vector3): void;
  65557. /**
  65558. * Release all resources
  65559. */
  65560. dispose(): void;
  65561. }
  65562. }
  65563. declare module BABYLON {
  65564. /**
  65565. * Class used to enable access to IndexedDB
  65566. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65567. */
  65568. export class Database implements IOfflineProvider {
  65569. private _callbackManifestChecked;
  65570. private _currentSceneUrl;
  65571. private _db;
  65572. private _enableSceneOffline;
  65573. private _enableTexturesOffline;
  65574. private _manifestVersionFound;
  65575. private _mustUpdateRessources;
  65576. private _hasReachedQuota;
  65577. private _isSupported;
  65578. private _idbFactory;
  65579. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65580. private static IsUASupportingBlobStorage;
  65581. /**
  65582. * Gets a boolean indicating if Database storate is enabled (off by default)
  65583. */
  65584. static IDBStorageEnabled: boolean;
  65585. /**
  65586. * Gets a boolean indicating if scene must be saved in the database
  65587. */
  65588. get enableSceneOffline(): boolean;
  65589. /**
  65590. * Gets a boolean indicating if textures must be saved in the database
  65591. */
  65592. get enableTexturesOffline(): boolean;
  65593. /**
  65594. * Creates a new Database
  65595. * @param urlToScene defines the url to load the scene
  65596. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65597. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65598. */
  65599. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65600. private static _ParseURL;
  65601. private static _ReturnFullUrlLocation;
  65602. private _checkManifestFile;
  65603. /**
  65604. * Open the database and make it available
  65605. * @param successCallback defines the callback to call on success
  65606. * @param errorCallback defines the callback to call on error
  65607. */
  65608. open(successCallback: () => void, errorCallback: () => void): void;
  65609. /**
  65610. * Loads an image from the database
  65611. * @param url defines the url to load from
  65612. * @param image defines the target DOM image
  65613. */
  65614. loadImage(url: string, image: HTMLImageElement): void;
  65615. private _loadImageFromDBAsync;
  65616. private _saveImageIntoDBAsync;
  65617. private _checkVersionFromDB;
  65618. private _loadVersionFromDBAsync;
  65619. private _saveVersionIntoDBAsync;
  65620. /**
  65621. * Loads a file from database
  65622. * @param url defines the URL to load from
  65623. * @param sceneLoaded defines a callback to call on success
  65624. * @param progressCallBack defines a callback to call when progress changed
  65625. * @param errorCallback defines a callback to call on error
  65626. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65627. */
  65628. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65629. private _loadFileAsync;
  65630. private _saveFileAsync;
  65631. /**
  65632. * Validates if xhr data is correct
  65633. * @param xhr defines the request to validate
  65634. * @param dataType defines the expected data type
  65635. * @returns true if data is correct
  65636. */
  65637. private static _ValidateXHRData;
  65638. }
  65639. }
  65640. declare module BABYLON {
  65641. /** @hidden */
  65642. export var gpuUpdateParticlesPixelShader: {
  65643. name: string;
  65644. shader: string;
  65645. };
  65646. }
  65647. declare module BABYLON {
  65648. /** @hidden */
  65649. export var gpuUpdateParticlesVertexShader: {
  65650. name: string;
  65651. shader: string;
  65652. };
  65653. }
  65654. declare module BABYLON {
  65655. /** @hidden */
  65656. export var clipPlaneFragmentDeclaration2: {
  65657. name: string;
  65658. shader: string;
  65659. };
  65660. }
  65661. declare module BABYLON {
  65662. /** @hidden */
  65663. export var gpuRenderParticlesPixelShader: {
  65664. name: string;
  65665. shader: string;
  65666. };
  65667. }
  65668. declare module BABYLON {
  65669. /** @hidden */
  65670. export var clipPlaneVertexDeclaration2: {
  65671. name: string;
  65672. shader: string;
  65673. };
  65674. }
  65675. declare module BABYLON {
  65676. /** @hidden */
  65677. export var gpuRenderParticlesVertexShader: {
  65678. name: string;
  65679. shader: string;
  65680. };
  65681. }
  65682. declare module BABYLON {
  65683. /**
  65684. * This represents a GPU particle system in Babylon
  65685. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65686. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65687. */
  65688. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65689. /**
  65690. * The layer mask we are rendering the particles through.
  65691. */
  65692. layerMask: number;
  65693. private _capacity;
  65694. private _activeCount;
  65695. private _currentActiveCount;
  65696. private _accumulatedCount;
  65697. private _renderEffect;
  65698. private _updateEffect;
  65699. private _buffer0;
  65700. private _buffer1;
  65701. private _spriteBuffer;
  65702. private _updateVAO;
  65703. private _renderVAO;
  65704. private _targetIndex;
  65705. private _sourceBuffer;
  65706. private _targetBuffer;
  65707. private _engine;
  65708. private _currentRenderId;
  65709. private _started;
  65710. private _stopped;
  65711. private _timeDelta;
  65712. private _randomTexture;
  65713. private _randomTexture2;
  65714. private _attributesStrideSize;
  65715. private _updateEffectOptions;
  65716. private _randomTextureSize;
  65717. private _actualFrame;
  65718. private _customEffect;
  65719. private readonly _rawTextureWidth;
  65720. /**
  65721. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65722. */
  65723. static get IsSupported(): boolean;
  65724. /**
  65725. * An event triggered when the system is disposed.
  65726. */
  65727. onDisposeObservable: Observable<IParticleSystem>;
  65728. /**
  65729. * Gets the maximum number of particles active at the same time.
  65730. * @returns The max number of active particles.
  65731. */
  65732. getCapacity(): number;
  65733. /**
  65734. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65735. * to override the particles.
  65736. */
  65737. forceDepthWrite: boolean;
  65738. /**
  65739. * Gets or set the number of active particles
  65740. */
  65741. get activeParticleCount(): number;
  65742. set activeParticleCount(value: number);
  65743. private _preWarmDone;
  65744. /**
  65745. * Specifies if the particles are updated in emitter local space or world space.
  65746. */
  65747. isLocal: boolean;
  65748. /**
  65749. * Is this system ready to be used/rendered
  65750. * @return true if the system is ready
  65751. */
  65752. isReady(): boolean;
  65753. /**
  65754. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65755. * @returns True if it has been started, otherwise false.
  65756. */
  65757. isStarted(): boolean;
  65758. /**
  65759. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  65760. * @returns True if it has been stopped, otherwise false.
  65761. */
  65762. isStopped(): boolean;
  65763. /**
  65764. * Gets a boolean indicating that the system is stopping
  65765. * @returns true if the system is currently stopping
  65766. */
  65767. isStopping(): boolean;
  65768. /**
  65769. * Gets the number of particles active at the same time.
  65770. * @returns The number of active particles.
  65771. */
  65772. getActiveCount(): number;
  65773. /**
  65774. * Starts the particle system and begins to emit
  65775. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65776. */
  65777. start(delay?: number): void;
  65778. /**
  65779. * Stops the particle system.
  65780. */
  65781. stop(): void;
  65782. /**
  65783. * Remove all active particles
  65784. */
  65785. reset(): void;
  65786. /**
  65787. * Returns the string "GPUParticleSystem"
  65788. * @returns a string containing the class name
  65789. */
  65790. getClassName(): string;
  65791. /**
  65792. * Gets the custom effect used to render the particles
  65793. * @param blendMode Blend mode for which the effect should be retrieved
  65794. * @returns The effect
  65795. */
  65796. getCustomEffect(blendMode?: number): Nullable<Effect>;
  65797. /**
  65798. * Sets the custom effect used to render the particles
  65799. * @param effect The effect to set
  65800. * @param blendMode Blend mode for which the effect should be set
  65801. */
  65802. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  65803. /** @hidden */
  65804. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  65805. /**
  65806. * Observable that will be called just before the particles are drawn
  65807. */
  65808. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  65809. /**
  65810. * Gets the name of the particle vertex shader
  65811. */
  65812. get vertexShaderName(): string;
  65813. private _colorGradientsTexture;
  65814. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65815. /**
  65816. * Adds a new color gradient
  65817. * @param gradient defines the gradient to use (between 0 and 1)
  65818. * @param color1 defines the color to affect to the specified gradient
  65819. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65820. * @returns the current particle system
  65821. */
  65822. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65823. private _refreshColorGradient;
  65824. /** Force the system to rebuild all gradients that need to be resync */
  65825. forceRefreshGradients(): void;
  65826. /**
  65827. * Remove a specific color gradient
  65828. * @param gradient defines the gradient to remove
  65829. * @returns the current particle system
  65830. */
  65831. removeColorGradient(gradient: number): GPUParticleSystem;
  65832. private _angularSpeedGradientsTexture;
  65833. private _sizeGradientsTexture;
  65834. private _velocityGradientsTexture;
  65835. private _limitVelocityGradientsTexture;
  65836. private _dragGradientsTexture;
  65837. private _addFactorGradient;
  65838. /**
  65839. * Adds a new size gradient
  65840. * @param gradient defines the gradient to use (between 0 and 1)
  65841. * @param factor defines the size factor to affect to the specified gradient
  65842. * @returns the current particle system
  65843. */
  65844. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65845. /**
  65846. * Remove a specific size gradient
  65847. * @param gradient defines the gradient to remove
  65848. * @returns the current particle system
  65849. */
  65850. removeSizeGradient(gradient: number): GPUParticleSystem;
  65851. private _refreshFactorGradient;
  65852. /**
  65853. * Adds a new angular speed gradient
  65854. * @param gradient defines the gradient to use (between 0 and 1)
  65855. * @param factor defines the angular speed to affect to the specified gradient
  65856. * @returns the current particle system
  65857. */
  65858. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65859. /**
  65860. * Remove a specific angular speed gradient
  65861. * @param gradient defines the gradient to remove
  65862. * @returns the current particle system
  65863. */
  65864. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65865. /**
  65866. * Adds a new velocity gradient
  65867. * @param gradient defines the gradient to use (between 0 and 1)
  65868. * @param factor defines the velocity to affect to the specified gradient
  65869. * @returns the current particle system
  65870. */
  65871. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65872. /**
  65873. * Remove a specific velocity gradient
  65874. * @param gradient defines the gradient to remove
  65875. * @returns the current particle system
  65876. */
  65877. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65878. /**
  65879. * Adds a new limit velocity gradient
  65880. * @param gradient defines the gradient to use (between 0 and 1)
  65881. * @param factor defines the limit velocity value to affect to the specified gradient
  65882. * @returns the current particle system
  65883. */
  65884. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65885. /**
  65886. * Remove a specific limit velocity gradient
  65887. * @param gradient defines the gradient to remove
  65888. * @returns the current particle system
  65889. */
  65890. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65891. /**
  65892. * Adds a new drag gradient
  65893. * @param gradient defines the gradient to use (between 0 and 1)
  65894. * @param factor defines the drag value to affect to the specified gradient
  65895. * @returns the current particle system
  65896. */
  65897. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65898. /**
  65899. * Remove a specific drag gradient
  65900. * @param gradient defines the gradient to remove
  65901. * @returns the current particle system
  65902. */
  65903. removeDragGradient(gradient: number): GPUParticleSystem;
  65904. /**
  65905. * Not supported by GPUParticleSystem
  65906. * @param gradient defines the gradient to use (between 0 and 1)
  65907. * @param factor defines the emit rate value to affect to the specified gradient
  65908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65909. * @returns the current particle system
  65910. */
  65911. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65912. /**
  65913. * Not supported by GPUParticleSystem
  65914. * @param gradient defines the gradient to remove
  65915. * @returns the current particle system
  65916. */
  65917. removeEmitRateGradient(gradient: number): IParticleSystem;
  65918. /**
  65919. * Not supported by GPUParticleSystem
  65920. * @param gradient defines the gradient to use (between 0 and 1)
  65921. * @param factor defines the start size value to affect to the specified gradient
  65922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65923. * @returns the current particle system
  65924. */
  65925. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65926. /**
  65927. * Not supported by GPUParticleSystem
  65928. * @param gradient defines the gradient to remove
  65929. * @returns the current particle system
  65930. */
  65931. removeStartSizeGradient(gradient: number): IParticleSystem;
  65932. /**
  65933. * Not supported by GPUParticleSystem
  65934. * @param gradient defines the gradient to use (between 0 and 1)
  65935. * @param min defines the color remap minimal range
  65936. * @param max defines the color remap maximal range
  65937. * @returns the current particle system
  65938. */
  65939. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65940. /**
  65941. * Not supported by GPUParticleSystem
  65942. * @param gradient defines the gradient to remove
  65943. * @returns the current particle system
  65944. */
  65945. removeColorRemapGradient(): IParticleSystem;
  65946. /**
  65947. * Not supported by GPUParticleSystem
  65948. * @param gradient defines the gradient to use (between 0 and 1)
  65949. * @param min defines the alpha remap minimal range
  65950. * @param max defines the alpha remap maximal range
  65951. * @returns the current particle system
  65952. */
  65953. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65954. /**
  65955. * Not supported by GPUParticleSystem
  65956. * @param gradient defines the gradient to remove
  65957. * @returns the current particle system
  65958. */
  65959. removeAlphaRemapGradient(): IParticleSystem;
  65960. /**
  65961. * Not supported by GPUParticleSystem
  65962. * @param gradient defines the gradient to use (between 0 and 1)
  65963. * @param color defines the color to affect to the specified gradient
  65964. * @returns the current particle system
  65965. */
  65966. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65967. /**
  65968. * Not supported by GPUParticleSystem
  65969. * @param gradient defines the gradient to remove
  65970. * @returns the current particle system
  65971. */
  65972. removeRampGradient(): IParticleSystem;
  65973. /**
  65974. * Not supported by GPUParticleSystem
  65975. * @returns the list of ramp gradients
  65976. */
  65977. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65978. /**
  65979. * Not supported by GPUParticleSystem
  65980. * Gets or sets a boolean indicating that ramp gradients must be used
  65981. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65982. */
  65983. get useRampGradients(): boolean;
  65984. set useRampGradients(value: boolean);
  65985. /**
  65986. * Not supported by GPUParticleSystem
  65987. * @param gradient defines the gradient to use (between 0 and 1)
  65988. * @param factor defines the life time factor to affect to the specified gradient
  65989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65990. * @returns the current particle system
  65991. */
  65992. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65993. /**
  65994. * Not supported by GPUParticleSystem
  65995. * @param gradient defines the gradient to remove
  65996. * @returns the current particle system
  65997. */
  65998. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65999. /**
  66000. * Instantiates a GPU particle system.
  66001. * 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.
  66002. * @param name The name of the particle system
  66003. * @param options The options used to create the system
  66004. * @param scene The scene the particle system belongs to
  66005. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66006. * @param customEffect a custom effect used to change the way particles are rendered by default
  66007. */
  66008. constructor(name: string, options: Partial<{
  66009. capacity: number;
  66010. randomTextureSize: number;
  66011. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66012. protected _reset(): void;
  66013. private _createUpdateVAO;
  66014. private _createRenderVAO;
  66015. private _initialize;
  66016. /** @hidden */
  66017. _recreateUpdateEffect(): void;
  66018. private _getEffect;
  66019. /**
  66020. * Fill the defines array according to the current settings of the particle system
  66021. * @param defines Array to be updated
  66022. * @param blendMode blend mode to take into account when updating the array
  66023. */
  66024. fillDefines(defines: Array<string>, blendMode?: number): void;
  66025. /**
  66026. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66027. * @param uniforms Uniforms array to fill
  66028. * @param attributes Attributes array to fill
  66029. * @param samplers Samplers array to fill
  66030. */
  66031. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66032. /** @hidden */
  66033. _recreateRenderEffect(): Effect;
  66034. /**
  66035. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66036. * @param preWarm defines if we are in the pre-warmimg phase
  66037. */
  66038. animate(preWarm?: boolean): void;
  66039. private _createFactorGradientTexture;
  66040. private _createSizeGradientTexture;
  66041. private _createAngularSpeedGradientTexture;
  66042. private _createVelocityGradientTexture;
  66043. private _createLimitVelocityGradientTexture;
  66044. private _createDragGradientTexture;
  66045. private _createColorGradientTexture;
  66046. /**
  66047. * Renders the particle system in its current state
  66048. * @param preWarm defines if the system should only update the particles but not render them
  66049. * @returns the current number of particles
  66050. */
  66051. render(preWarm?: boolean): number;
  66052. /**
  66053. * Rebuilds the particle system
  66054. */
  66055. rebuild(): void;
  66056. private _releaseBuffers;
  66057. private _releaseVAOs;
  66058. /**
  66059. * Disposes the particle system and free the associated resources
  66060. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66061. */
  66062. dispose(disposeTexture?: boolean): void;
  66063. /**
  66064. * Clones the particle system.
  66065. * @param name The name of the cloned object
  66066. * @param newEmitter The new emitter to use
  66067. * @returns the cloned particle system
  66068. */
  66069. clone(name: string, newEmitter: any): GPUParticleSystem;
  66070. /**
  66071. * Serializes the particle system to a JSON object
  66072. * @param serializeTexture defines if the texture must be serialized as well
  66073. * @returns the JSON object
  66074. */
  66075. serialize(serializeTexture?: boolean): any;
  66076. /**
  66077. * Parses a JSON object to create a GPU particle system.
  66078. * @param parsedParticleSystem The JSON object to parse
  66079. * @param scene The scene to create the particle system in
  66080. * @param rootUrl The root url to use to load external dependencies like texture
  66081. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66082. * @returns the parsed GPU particle system
  66083. */
  66084. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66085. }
  66086. }
  66087. declare module BABYLON {
  66088. /**
  66089. * Represents a set of particle systems working together to create a specific effect
  66090. */
  66091. export class ParticleSystemSet implements IDisposable {
  66092. /**
  66093. * Gets or sets base Assets URL
  66094. */
  66095. static BaseAssetsUrl: string;
  66096. private _emitterCreationOptions;
  66097. private _emitterNode;
  66098. /**
  66099. * Gets the particle system list
  66100. */
  66101. systems: IParticleSystem[];
  66102. /**
  66103. * Gets the emitter node used with this set
  66104. */
  66105. get emitterNode(): Nullable<TransformNode>;
  66106. /**
  66107. * Creates a new emitter mesh as a sphere
  66108. * @param options defines the options used to create the sphere
  66109. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66110. * @param scene defines the hosting scene
  66111. */
  66112. setEmitterAsSphere(options: {
  66113. diameter: number;
  66114. segments: number;
  66115. color: Color3;
  66116. }, renderingGroupId: number, scene: Scene): void;
  66117. /**
  66118. * Starts all particle systems of the set
  66119. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66120. */
  66121. start(emitter?: AbstractMesh): void;
  66122. /**
  66123. * Release all associated resources
  66124. */
  66125. dispose(): void;
  66126. /**
  66127. * Serialize the set into a JSON compatible object
  66128. * @param serializeTexture defines if the texture must be serialized as well
  66129. * @returns a JSON compatible representation of the set
  66130. */
  66131. serialize(serializeTexture?: boolean): any;
  66132. /**
  66133. * Parse a new ParticleSystemSet from a serialized source
  66134. * @param data defines a JSON compatible representation of the set
  66135. * @param scene defines the hosting scene
  66136. * @param gpu defines if we want GPU particles or CPU particles
  66137. * @returns a new ParticleSystemSet
  66138. */
  66139. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66140. }
  66141. }
  66142. declare module BABYLON {
  66143. /**
  66144. * This class is made for on one-liner static method to help creating particle system set.
  66145. */
  66146. export class ParticleHelper {
  66147. /**
  66148. * Gets or sets base Assets URL
  66149. */
  66150. static BaseAssetsUrl: string;
  66151. /** Define the Url to load snippets */
  66152. static SnippetUrl: string;
  66153. /**
  66154. * Create a default particle system that you can tweak
  66155. * @param emitter defines the emitter to use
  66156. * @param capacity defines the system capacity (default is 500 particles)
  66157. * @param scene defines the hosting scene
  66158. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66159. * @returns the new Particle system
  66160. */
  66161. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66162. /**
  66163. * This is the main static method (one-liner) of this helper to create different particle systems
  66164. * @param type This string represents the type to the particle system to create
  66165. * @param scene The scene where the particle system should live
  66166. * @param gpu If the system will use gpu
  66167. * @returns the ParticleSystemSet created
  66168. */
  66169. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66170. /**
  66171. * Static function used to export a particle system to a ParticleSystemSet variable.
  66172. * Please note that the emitter shape is not exported
  66173. * @param systems defines the particle systems to export
  66174. * @returns the created particle system set
  66175. */
  66176. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66177. /**
  66178. * Creates a particle system from a snippet saved in a remote file
  66179. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66180. * @param url defines the url to load from
  66181. * @param scene defines the hosting scene
  66182. * @param gpu If the system will use gpu
  66183. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66184. * @returns a promise that will resolve to the new particle system
  66185. */
  66186. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66187. /**
  66188. * Creates a particle system from a snippet saved by the particle system editor
  66189. * @param snippetId defines the snippet to load
  66190. * @param scene defines the hosting scene
  66191. * @param gpu If the system will use gpu
  66192. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66193. * @returns a promise that will resolve to the new particle system
  66194. */
  66195. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66196. }
  66197. }
  66198. declare module BABYLON {
  66199. interface Engine {
  66200. /**
  66201. * Create an effect to use with particle systems.
  66202. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66203. * the particle system for which you want to create a custom effect in the last parameter
  66204. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66205. * @param uniformsNames defines a list of attribute names
  66206. * @param samplers defines an array of string used to represent textures
  66207. * @param defines defines the string containing the defines to use to compile the shaders
  66208. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66209. * @param onCompiled defines a function to call when the effect creation is successful
  66210. * @param onError defines a function to call when the effect creation has failed
  66211. * @param particleSystem the particle system you want to create the effect for
  66212. * @returns the new Effect
  66213. */
  66214. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66215. }
  66216. interface Mesh {
  66217. /**
  66218. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66219. * @returns an array of IParticleSystem
  66220. */
  66221. getEmittedParticleSystems(): IParticleSystem[];
  66222. /**
  66223. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66224. * @returns an array of IParticleSystem
  66225. */
  66226. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66227. }
  66228. }
  66229. declare module BABYLON {
  66230. /** Defines the 4 color options */
  66231. export enum PointColor {
  66232. /** color value */
  66233. Color = 2,
  66234. /** uv value */
  66235. UV = 1,
  66236. /** random value */
  66237. Random = 0,
  66238. /** stated value */
  66239. Stated = 3
  66240. }
  66241. /**
  66242. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66243. * 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.
  66244. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66245. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66246. *
  66247. * Full documentation here : TO BE ENTERED
  66248. */
  66249. export class PointsCloudSystem implements IDisposable {
  66250. /**
  66251. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66252. * Example : var p = SPS.particles[i];
  66253. */
  66254. particles: CloudPoint[];
  66255. /**
  66256. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66257. */
  66258. nbParticles: number;
  66259. /**
  66260. * This a counter for your own usage. It's not set by any SPS functions.
  66261. */
  66262. counter: number;
  66263. /**
  66264. * The PCS name. This name is also given to the underlying mesh.
  66265. */
  66266. name: string;
  66267. /**
  66268. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66269. */
  66270. mesh: Mesh;
  66271. /**
  66272. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66273. * Please read :
  66274. */
  66275. vars: any;
  66276. /**
  66277. * @hidden
  66278. */
  66279. _size: number;
  66280. private _scene;
  66281. private _promises;
  66282. private _positions;
  66283. private _indices;
  66284. private _normals;
  66285. private _colors;
  66286. private _uvs;
  66287. private _indices32;
  66288. private _positions32;
  66289. private _colors32;
  66290. private _uvs32;
  66291. private _updatable;
  66292. private _isVisibilityBoxLocked;
  66293. private _alwaysVisible;
  66294. private _groups;
  66295. private _groupCounter;
  66296. private _computeParticleColor;
  66297. private _computeParticleTexture;
  66298. private _computeParticleRotation;
  66299. private _computeBoundingBox;
  66300. private _isReady;
  66301. /**
  66302. * Creates a PCS (Points Cloud System) object
  66303. * @param name (String) is the PCS name, this will be the underlying mesh name
  66304. * @param pointSize (number) is the size for each point
  66305. * @param scene (Scene) is the scene in which the PCS is added
  66306. * @param options defines the options of the PCS e.g.
  66307. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66308. */
  66309. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66310. updatable?: boolean;
  66311. });
  66312. /**
  66313. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66314. * If no points were added to the PCS, the returned mesh is just a single point.
  66315. * @returns a promise for the created mesh
  66316. */
  66317. buildMeshAsync(): Promise<Mesh>;
  66318. /**
  66319. * @hidden
  66320. */
  66321. private _buildMesh;
  66322. private _addParticle;
  66323. private _randomUnitVector;
  66324. private _getColorIndicesForCoord;
  66325. private _setPointsColorOrUV;
  66326. private _colorFromTexture;
  66327. private _calculateDensity;
  66328. /**
  66329. * Adds points to the PCS in random positions within a unit sphere
  66330. * @param nb (positive integer) the number of particles to be created from this model
  66331. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66332. * @returns the number of groups in the system
  66333. */
  66334. addPoints(nb: number, pointFunction?: any): number;
  66335. /**
  66336. * Adds points to the PCS from the surface of the model shape
  66337. * @param mesh is any Mesh object that will be used as a surface model for the points
  66338. * @param nb (positive integer) the number of particles to be created from this model
  66339. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66340. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66341. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66342. * @returns the number of groups in the system
  66343. */
  66344. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66345. /**
  66346. * Adds points to the PCS inside the model shape
  66347. * @param mesh is any Mesh object that will be used as a surface model for the points
  66348. * @param nb (positive integer) the number of particles to be created from this model
  66349. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66350. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66351. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66352. * @returns the number of groups in the system
  66353. */
  66354. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66355. /**
  66356. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66357. * This method calls `updateParticle()` for each particle of the SPS.
  66358. * For an animated SPS, it is usually called within the render loop.
  66359. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66360. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66361. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66362. * @returns the PCS.
  66363. */
  66364. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66365. /**
  66366. * Disposes the PCS.
  66367. */
  66368. dispose(): void;
  66369. /**
  66370. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66371. * doc :
  66372. * @returns the PCS.
  66373. */
  66374. refreshVisibleSize(): PointsCloudSystem;
  66375. /**
  66376. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66377. * @param size the size (float) of the visibility box
  66378. * note : this doesn't lock the PCS mesh bounding box.
  66379. * doc :
  66380. */
  66381. setVisibilityBox(size: number): void;
  66382. /**
  66383. * Gets whether the PCS is always visible or not
  66384. * doc :
  66385. */
  66386. get isAlwaysVisible(): boolean;
  66387. /**
  66388. * Sets the PCS as always visible or not
  66389. * doc :
  66390. */
  66391. set isAlwaysVisible(val: boolean);
  66392. /**
  66393. * Tells to `setParticles()` to compute the particle rotations or not
  66394. * Default value : false. The PCS is faster when it's set to false
  66395. * Note : particle rotations are only applied to parent particles
  66396. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66397. */
  66398. set computeParticleRotation(val: boolean);
  66399. /**
  66400. * Tells to `setParticles()` to compute the particle colors or not.
  66401. * Default value : true. The PCS is faster when it's set to false.
  66402. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66403. */
  66404. set computeParticleColor(val: boolean);
  66405. set computeParticleTexture(val: boolean);
  66406. /**
  66407. * Gets if `setParticles()` computes the particle colors or not.
  66408. * Default value : false. The PCS is faster when it's set to false.
  66409. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66410. */
  66411. get computeParticleColor(): boolean;
  66412. /**
  66413. * Gets if `setParticles()` computes the particle textures or not.
  66414. * Default value : false. The PCS is faster when it's set to false.
  66415. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66416. */
  66417. get computeParticleTexture(): boolean;
  66418. /**
  66419. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66420. */
  66421. set computeBoundingBox(val: boolean);
  66422. /**
  66423. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66424. */
  66425. get computeBoundingBox(): boolean;
  66426. /**
  66427. * This function does nothing. It may be overwritten to set all the particle first values.
  66428. * The PCS doesn't call this function, you may have to call it by your own.
  66429. * doc :
  66430. */
  66431. initParticles(): void;
  66432. /**
  66433. * This function does nothing. It may be overwritten to recycle a particle
  66434. * The PCS doesn't call this function, you can to call it
  66435. * doc :
  66436. * @param particle The particle to recycle
  66437. * @returns the recycled particle
  66438. */
  66439. recycleParticle(particle: CloudPoint): CloudPoint;
  66440. /**
  66441. * Updates a particle : this function should be overwritten by the user.
  66442. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66443. * doc :
  66444. * @example : just set a particle position or velocity and recycle conditions
  66445. * @param particle The particle to update
  66446. * @returns the updated particle
  66447. */
  66448. updateParticle(particle: CloudPoint): CloudPoint;
  66449. /**
  66450. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66451. * This does nothing and may be overwritten by the user.
  66452. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66453. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66454. * @param update the boolean update value actually passed to setParticles()
  66455. */
  66456. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66457. /**
  66458. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66459. * This will be passed three parameters.
  66460. * This does nothing and may be overwritten by the user.
  66461. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66462. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66463. * @param update the boolean update value actually passed to setParticles()
  66464. */
  66465. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66466. }
  66467. }
  66468. declare module BABYLON {
  66469. /**
  66470. * Represents one particle of a points cloud system.
  66471. */
  66472. export class CloudPoint {
  66473. /**
  66474. * particle global index
  66475. */
  66476. idx: number;
  66477. /**
  66478. * The color of the particle
  66479. */
  66480. color: Nullable<Color4>;
  66481. /**
  66482. * The world space position of the particle.
  66483. */
  66484. position: Vector3;
  66485. /**
  66486. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66487. */
  66488. rotation: Vector3;
  66489. /**
  66490. * The world space rotation quaternion of the particle.
  66491. */
  66492. rotationQuaternion: Nullable<Quaternion>;
  66493. /**
  66494. * The uv of the particle.
  66495. */
  66496. uv: Nullable<Vector2>;
  66497. /**
  66498. * The current speed of the particle.
  66499. */
  66500. velocity: Vector3;
  66501. /**
  66502. * The pivot point in the particle local space.
  66503. */
  66504. pivot: Vector3;
  66505. /**
  66506. * Must the particle be translated from its pivot point in its local space ?
  66507. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66508. * Default : false
  66509. */
  66510. translateFromPivot: boolean;
  66511. /**
  66512. * Index of this particle in the global "positions" array (Internal use)
  66513. * @hidden
  66514. */
  66515. _pos: number;
  66516. /**
  66517. * @hidden Index of this particle in the global "indices" array (Internal use)
  66518. */
  66519. _ind: number;
  66520. /**
  66521. * Group this particle belongs to
  66522. */
  66523. _group: PointsGroup;
  66524. /**
  66525. * Group id of this particle
  66526. */
  66527. groupId: number;
  66528. /**
  66529. * Index of the particle in its group id (Internal use)
  66530. */
  66531. idxInGroup: number;
  66532. /**
  66533. * @hidden Particle BoundingInfo object (Internal use)
  66534. */
  66535. _boundingInfo: BoundingInfo;
  66536. /**
  66537. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66538. */
  66539. _pcs: PointsCloudSystem;
  66540. /**
  66541. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66542. */
  66543. _stillInvisible: boolean;
  66544. /**
  66545. * @hidden Last computed particle rotation matrix
  66546. */
  66547. _rotationMatrix: number[];
  66548. /**
  66549. * Parent particle Id, if any.
  66550. * Default null.
  66551. */
  66552. parentId: Nullable<number>;
  66553. /**
  66554. * @hidden Internal global position in the PCS.
  66555. */
  66556. _globalPosition: Vector3;
  66557. /**
  66558. * Creates a Point Cloud object.
  66559. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66560. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66561. * @param group (PointsGroup) is the group the particle belongs to
  66562. * @param groupId (integer) is the group identifier in the PCS.
  66563. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66564. * @param pcs defines the PCS it is associated to
  66565. */
  66566. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66567. /**
  66568. * get point size
  66569. */
  66570. get size(): Vector3;
  66571. /**
  66572. * Set point size
  66573. */
  66574. set size(scale: Vector3);
  66575. /**
  66576. * Legacy support, changed quaternion to rotationQuaternion
  66577. */
  66578. get quaternion(): Nullable<Quaternion>;
  66579. /**
  66580. * Legacy support, changed quaternion to rotationQuaternion
  66581. */
  66582. set quaternion(q: Nullable<Quaternion>);
  66583. /**
  66584. * Returns a boolean. True if the particle intersects a mesh, else false
  66585. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66586. * @param target is the object (point or mesh) what the intersection is computed against
  66587. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66588. * @returns true if it intersects
  66589. */
  66590. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66591. /**
  66592. * get the rotation matrix of the particle
  66593. * @hidden
  66594. */
  66595. getRotationMatrix(m: Matrix): void;
  66596. }
  66597. /**
  66598. * Represents a group of points in a points cloud system
  66599. * * PCS internal tool, don't use it manually.
  66600. */
  66601. export class PointsGroup {
  66602. /**
  66603. * The group id
  66604. * @hidden
  66605. */
  66606. groupID: number;
  66607. /**
  66608. * image data for group (internal use)
  66609. * @hidden
  66610. */
  66611. _groupImageData: Nullable<ArrayBufferView>;
  66612. /**
  66613. * Image Width (internal use)
  66614. * @hidden
  66615. */
  66616. _groupImgWidth: number;
  66617. /**
  66618. * Image Height (internal use)
  66619. * @hidden
  66620. */
  66621. _groupImgHeight: number;
  66622. /**
  66623. * Custom position function (internal use)
  66624. * @hidden
  66625. */
  66626. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66627. /**
  66628. * density per facet for surface points
  66629. * @hidden
  66630. */
  66631. _groupDensity: number[];
  66632. /**
  66633. * Only when points are colored by texture carries pointer to texture list array
  66634. * @hidden
  66635. */
  66636. _textureNb: number;
  66637. /**
  66638. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66639. * PCS internal tool, don't use it manually.
  66640. * @hidden
  66641. */
  66642. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66643. }
  66644. }
  66645. declare module BABYLON {
  66646. interface Scene {
  66647. /** @hidden (Backing field) */
  66648. _physicsEngine: Nullable<IPhysicsEngine>;
  66649. /** @hidden */
  66650. _physicsTimeAccumulator: number;
  66651. /**
  66652. * Gets the current physics engine
  66653. * @returns a IPhysicsEngine or null if none attached
  66654. */
  66655. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66656. /**
  66657. * Enables physics to the current scene
  66658. * @param gravity defines the scene's gravity for the physics engine
  66659. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66660. * @return a boolean indicating if the physics engine was initialized
  66661. */
  66662. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66663. /**
  66664. * Disables and disposes the physics engine associated with the scene
  66665. */
  66666. disablePhysicsEngine(): void;
  66667. /**
  66668. * Gets a boolean indicating if there is an active physics engine
  66669. * @returns a boolean indicating if there is an active physics engine
  66670. */
  66671. isPhysicsEnabled(): boolean;
  66672. /**
  66673. * Deletes a physics compound impostor
  66674. * @param compound defines the compound to delete
  66675. */
  66676. deleteCompoundImpostor(compound: any): void;
  66677. /**
  66678. * An event triggered when physic simulation is about to be run
  66679. */
  66680. onBeforePhysicsObservable: Observable<Scene>;
  66681. /**
  66682. * An event triggered when physic simulation has been done
  66683. */
  66684. onAfterPhysicsObservable: Observable<Scene>;
  66685. }
  66686. interface AbstractMesh {
  66687. /** @hidden */
  66688. _physicsImpostor: Nullable<PhysicsImpostor>;
  66689. /**
  66690. * Gets or sets impostor used for physic simulation
  66691. * @see http://doc.babylonjs.com/features/physics_engine
  66692. */
  66693. physicsImpostor: Nullable<PhysicsImpostor>;
  66694. /**
  66695. * Gets the current physics impostor
  66696. * @see http://doc.babylonjs.com/features/physics_engine
  66697. * @returns a physics impostor or null
  66698. */
  66699. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66700. /** Apply a physic impulse to the mesh
  66701. * @param force defines the force to apply
  66702. * @param contactPoint defines where to apply the force
  66703. * @returns the current mesh
  66704. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66705. */
  66706. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66707. /**
  66708. * Creates a physic joint between two meshes
  66709. * @param otherMesh defines the other mesh to use
  66710. * @param pivot1 defines the pivot to use on this mesh
  66711. * @param pivot2 defines the pivot to use on the other mesh
  66712. * @param options defines additional options (can be plugin dependent)
  66713. * @returns the current mesh
  66714. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66715. */
  66716. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66717. /** @hidden */
  66718. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66719. }
  66720. /**
  66721. * Defines the physics engine scene component responsible to manage a physics engine
  66722. */
  66723. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66724. /**
  66725. * The component name helpful to identify the component in the list of scene components.
  66726. */
  66727. readonly name: string;
  66728. /**
  66729. * The scene the component belongs to.
  66730. */
  66731. scene: Scene;
  66732. /**
  66733. * Creates a new instance of the component for the given scene
  66734. * @param scene Defines the scene to register the component in
  66735. */
  66736. constructor(scene: Scene);
  66737. /**
  66738. * Registers the component in a given scene
  66739. */
  66740. register(): void;
  66741. /**
  66742. * Rebuilds the elements related to this component in case of
  66743. * context lost for instance.
  66744. */
  66745. rebuild(): void;
  66746. /**
  66747. * Disposes the component and the associated ressources
  66748. */
  66749. dispose(): void;
  66750. }
  66751. }
  66752. declare module BABYLON {
  66753. /**
  66754. * A helper for physics simulations
  66755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66756. */
  66757. export class PhysicsHelper {
  66758. private _scene;
  66759. private _physicsEngine;
  66760. /**
  66761. * Initializes the Physics helper
  66762. * @param scene Babylon.js scene
  66763. */
  66764. constructor(scene: Scene);
  66765. /**
  66766. * Applies a radial explosion impulse
  66767. * @param origin the origin of the explosion
  66768. * @param radiusOrEventOptions the radius or the options of radial explosion
  66769. * @param strength the explosion strength
  66770. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66771. * @returns A physics radial explosion event, or null
  66772. */
  66773. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66774. /**
  66775. * Applies a radial explosion force
  66776. * @param origin the origin of the explosion
  66777. * @param radiusOrEventOptions the radius or the options of radial explosion
  66778. * @param strength the explosion strength
  66779. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66780. * @returns A physics radial explosion event, or null
  66781. */
  66782. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66783. /**
  66784. * Creates a gravitational field
  66785. * @param origin the origin of the explosion
  66786. * @param radiusOrEventOptions the radius or the options of radial explosion
  66787. * @param strength the explosion strength
  66788. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66789. * @returns A physics gravitational field event, or null
  66790. */
  66791. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66792. /**
  66793. * Creates a physics updraft event
  66794. * @param origin the origin of the updraft
  66795. * @param radiusOrEventOptions the radius or the options of the updraft
  66796. * @param strength the strength of the updraft
  66797. * @param height the height of the updraft
  66798. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66799. * @returns A physics updraft event, or null
  66800. */
  66801. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66802. /**
  66803. * Creates a physics vortex event
  66804. * @param origin the of the vortex
  66805. * @param radiusOrEventOptions the radius or the options of the vortex
  66806. * @param strength the strength of the vortex
  66807. * @param height the height of the vortex
  66808. * @returns a Physics vortex event, or null
  66809. * A physics vortex event or null
  66810. */
  66811. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66812. }
  66813. /**
  66814. * Represents a physics radial explosion event
  66815. */
  66816. class PhysicsRadialExplosionEvent {
  66817. private _scene;
  66818. private _options;
  66819. private _sphere;
  66820. private _dataFetched;
  66821. /**
  66822. * Initializes a radial explosioin event
  66823. * @param _scene BabylonJS scene
  66824. * @param _options The options for the vortex event
  66825. */
  66826. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66827. /**
  66828. * Returns the data related to the radial explosion event (sphere).
  66829. * @returns The radial explosion event data
  66830. */
  66831. getData(): PhysicsRadialExplosionEventData;
  66832. /**
  66833. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66834. * @param impostor A physics imposter
  66835. * @param origin the origin of the explosion
  66836. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66837. */
  66838. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66839. /**
  66840. * Triggers affecterd impostors callbacks
  66841. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66842. */
  66843. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66844. /**
  66845. * Disposes the sphere.
  66846. * @param force Specifies if the sphere should be disposed by force
  66847. */
  66848. dispose(force?: boolean): void;
  66849. /*** Helpers ***/
  66850. private _prepareSphere;
  66851. private _intersectsWithSphere;
  66852. }
  66853. /**
  66854. * Represents a gravitational field event
  66855. */
  66856. class PhysicsGravitationalFieldEvent {
  66857. private _physicsHelper;
  66858. private _scene;
  66859. private _origin;
  66860. private _options;
  66861. private _tickCallback;
  66862. private _sphere;
  66863. private _dataFetched;
  66864. /**
  66865. * Initializes the physics gravitational field event
  66866. * @param _physicsHelper A physics helper
  66867. * @param _scene BabylonJS scene
  66868. * @param _origin The origin position of the gravitational field event
  66869. * @param _options The options for the vortex event
  66870. */
  66871. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66872. /**
  66873. * Returns the data related to the gravitational field event (sphere).
  66874. * @returns A gravitational field event
  66875. */
  66876. getData(): PhysicsGravitationalFieldEventData;
  66877. /**
  66878. * Enables the gravitational field.
  66879. */
  66880. enable(): void;
  66881. /**
  66882. * Disables the gravitational field.
  66883. */
  66884. disable(): void;
  66885. /**
  66886. * Disposes the sphere.
  66887. * @param force The force to dispose from the gravitational field event
  66888. */
  66889. dispose(force?: boolean): void;
  66890. private _tick;
  66891. }
  66892. /**
  66893. * Represents a physics updraft event
  66894. */
  66895. class PhysicsUpdraftEvent {
  66896. private _scene;
  66897. private _origin;
  66898. private _options;
  66899. private _physicsEngine;
  66900. private _originTop;
  66901. private _originDirection;
  66902. private _tickCallback;
  66903. private _cylinder;
  66904. private _cylinderPosition;
  66905. private _dataFetched;
  66906. /**
  66907. * Initializes the physics updraft event
  66908. * @param _scene BabylonJS scene
  66909. * @param _origin The origin position of the updraft
  66910. * @param _options The options for the updraft event
  66911. */
  66912. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66913. /**
  66914. * Returns the data related to the updraft event (cylinder).
  66915. * @returns A physics updraft event
  66916. */
  66917. getData(): PhysicsUpdraftEventData;
  66918. /**
  66919. * Enables the updraft.
  66920. */
  66921. enable(): void;
  66922. /**
  66923. * Disables the updraft.
  66924. */
  66925. disable(): void;
  66926. /**
  66927. * Disposes the cylinder.
  66928. * @param force Specifies if the updraft should be disposed by force
  66929. */
  66930. dispose(force?: boolean): void;
  66931. private getImpostorHitData;
  66932. private _tick;
  66933. /*** Helpers ***/
  66934. private _prepareCylinder;
  66935. private _intersectsWithCylinder;
  66936. }
  66937. /**
  66938. * Represents a physics vortex event
  66939. */
  66940. class PhysicsVortexEvent {
  66941. private _scene;
  66942. private _origin;
  66943. private _options;
  66944. private _physicsEngine;
  66945. private _originTop;
  66946. private _tickCallback;
  66947. private _cylinder;
  66948. private _cylinderPosition;
  66949. private _dataFetched;
  66950. /**
  66951. * Initializes the physics vortex event
  66952. * @param _scene The BabylonJS scene
  66953. * @param _origin The origin position of the vortex
  66954. * @param _options The options for the vortex event
  66955. */
  66956. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66957. /**
  66958. * Returns the data related to the vortex event (cylinder).
  66959. * @returns The physics vortex event data
  66960. */
  66961. getData(): PhysicsVortexEventData;
  66962. /**
  66963. * Enables the vortex.
  66964. */
  66965. enable(): void;
  66966. /**
  66967. * Disables the cortex.
  66968. */
  66969. disable(): void;
  66970. /**
  66971. * Disposes the sphere.
  66972. * @param force
  66973. */
  66974. dispose(force?: boolean): void;
  66975. private getImpostorHitData;
  66976. private _tick;
  66977. /*** Helpers ***/
  66978. private _prepareCylinder;
  66979. private _intersectsWithCylinder;
  66980. }
  66981. /**
  66982. * Options fot the radial explosion event
  66983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66984. */
  66985. export class PhysicsRadialExplosionEventOptions {
  66986. /**
  66987. * The radius of the sphere for the radial explosion.
  66988. */
  66989. radius: number;
  66990. /**
  66991. * The strenth of the explosion.
  66992. */
  66993. strength: number;
  66994. /**
  66995. * The strenght of the force in correspondence to the distance of the affected object
  66996. */
  66997. falloff: PhysicsRadialImpulseFalloff;
  66998. /**
  66999. * Sphere options for the radial explosion.
  67000. */
  67001. sphere: {
  67002. segments: number;
  67003. diameter: number;
  67004. };
  67005. /**
  67006. * Sphere options for the radial explosion.
  67007. */
  67008. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67009. }
  67010. /**
  67011. * Options fot the updraft event
  67012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67013. */
  67014. export class PhysicsUpdraftEventOptions {
  67015. /**
  67016. * The radius of the cylinder for the vortex
  67017. */
  67018. radius: number;
  67019. /**
  67020. * The strenth of the updraft.
  67021. */
  67022. strength: number;
  67023. /**
  67024. * The height of the cylinder for the updraft.
  67025. */
  67026. height: number;
  67027. /**
  67028. * The mode for the the updraft.
  67029. */
  67030. updraftMode: PhysicsUpdraftMode;
  67031. }
  67032. /**
  67033. * Options fot the vortex event
  67034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67035. */
  67036. export class PhysicsVortexEventOptions {
  67037. /**
  67038. * The radius of the cylinder for the vortex
  67039. */
  67040. radius: number;
  67041. /**
  67042. * The strenth of the vortex.
  67043. */
  67044. strength: number;
  67045. /**
  67046. * The height of the cylinder for the vortex.
  67047. */
  67048. height: number;
  67049. /**
  67050. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67051. */
  67052. centripetalForceThreshold: number;
  67053. /**
  67054. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67055. */
  67056. centripetalForceMultiplier: number;
  67057. /**
  67058. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67059. */
  67060. centrifugalForceMultiplier: number;
  67061. /**
  67062. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67063. */
  67064. updraftForceMultiplier: number;
  67065. }
  67066. /**
  67067. * The strenght of the force in correspondence to the distance of the affected object
  67068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67069. */
  67070. export enum PhysicsRadialImpulseFalloff {
  67071. /** Defines that impulse is constant in strength across it's whole radius */
  67072. Constant = 0,
  67073. /** Defines that impulse gets weaker if it's further from the origin */
  67074. Linear = 1
  67075. }
  67076. /**
  67077. * The strength of the force in correspondence to the distance of the affected object
  67078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67079. */
  67080. export enum PhysicsUpdraftMode {
  67081. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67082. Center = 0,
  67083. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67084. Perpendicular = 1
  67085. }
  67086. /**
  67087. * Interface for a physics hit data
  67088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67089. */
  67090. export interface PhysicsHitData {
  67091. /**
  67092. * The force applied at the contact point
  67093. */
  67094. force: Vector3;
  67095. /**
  67096. * The contact point
  67097. */
  67098. contactPoint: Vector3;
  67099. /**
  67100. * The distance from the origin to the contact point
  67101. */
  67102. distanceFromOrigin: number;
  67103. }
  67104. /**
  67105. * Interface for radial explosion event data
  67106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67107. */
  67108. export interface PhysicsRadialExplosionEventData {
  67109. /**
  67110. * A sphere used for the radial explosion event
  67111. */
  67112. sphere: Mesh;
  67113. }
  67114. /**
  67115. * Interface for gravitational field event data
  67116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67117. */
  67118. export interface PhysicsGravitationalFieldEventData {
  67119. /**
  67120. * A sphere mesh used for the gravitational field event
  67121. */
  67122. sphere: Mesh;
  67123. }
  67124. /**
  67125. * Interface for updraft event data
  67126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67127. */
  67128. export interface PhysicsUpdraftEventData {
  67129. /**
  67130. * A cylinder used for the updraft event
  67131. */
  67132. cylinder: Mesh;
  67133. }
  67134. /**
  67135. * Interface for vortex event data
  67136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67137. */
  67138. export interface PhysicsVortexEventData {
  67139. /**
  67140. * A cylinder used for the vortex event
  67141. */
  67142. cylinder: Mesh;
  67143. }
  67144. /**
  67145. * Interface for an affected physics impostor
  67146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67147. */
  67148. export interface PhysicsAffectedImpostorWithData {
  67149. /**
  67150. * The impostor affected by the effect
  67151. */
  67152. impostor: PhysicsImpostor;
  67153. /**
  67154. * The data about the hit/horce from the explosion
  67155. */
  67156. hitData: PhysicsHitData;
  67157. }
  67158. }
  67159. declare module BABYLON {
  67160. /** @hidden */
  67161. export var blackAndWhitePixelShader: {
  67162. name: string;
  67163. shader: string;
  67164. };
  67165. }
  67166. declare module BABYLON {
  67167. /**
  67168. * Post process used to render in black and white
  67169. */
  67170. export class BlackAndWhitePostProcess extends PostProcess {
  67171. /**
  67172. * Linear about to convert he result to black and white (default: 1)
  67173. */
  67174. degree: number;
  67175. /**
  67176. * Creates a black and white post process
  67177. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67178. * @param name The name of the effect.
  67179. * @param options The required width/height ratio to downsize to before computing the render pass.
  67180. * @param camera The camera to apply the render pass to.
  67181. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67182. * @param engine The engine which the post process will be applied. (default: current engine)
  67183. * @param reusable If the post process can be reused on the same frame. (default: false)
  67184. */
  67185. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67186. }
  67187. }
  67188. declare module BABYLON {
  67189. /**
  67190. * This represents a set of one or more post processes in Babylon.
  67191. * A post process can be used to apply a shader to a texture after it is rendered.
  67192. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67193. */
  67194. export class PostProcessRenderEffect {
  67195. private _postProcesses;
  67196. private _getPostProcesses;
  67197. private _singleInstance;
  67198. private _cameras;
  67199. private _indicesForCamera;
  67200. /**
  67201. * Name of the effect
  67202. * @hidden
  67203. */
  67204. _name: string;
  67205. /**
  67206. * Instantiates a post process render effect.
  67207. * A post process can be used to apply a shader to a texture after it is rendered.
  67208. * @param engine The engine the effect is tied to
  67209. * @param name The name of the effect
  67210. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67211. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67212. */
  67213. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67214. /**
  67215. * Checks if all the post processes in the effect are supported.
  67216. */
  67217. get isSupported(): boolean;
  67218. /**
  67219. * Updates the current state of the effect
  67220. * @hidden
  67221. */
  67222. _update(): void;
  67223. /**
  67224. * Attaches the effect on cameras
  67225. * @param cameras The camera to attach to.
  67226. * @hidden
  67227. */
  67228. _attachCameras(cameras: Camera): void;
  67229. /**
  67230. * Attaches the effect on cameras
  67231. * @param cameras The camera to attach to.
  67232. * @hidden
  67233. */
  67234. _attachCameras(cameras: Camera[]): void;
  67235. /**
  67236. * Detaches the effect on cameras
  67237. * @param cameras The camera to detatch from.
  67238. * @hidden
  67239. */
  67240. _detachCameras(cameras: Camera): void;
  67241. /**
  67242. * Detatches the effect on cameras
  67243. * @param cameras The camera to detatch from.
  67244. * @hidden
  67245. */
  67246. _detachCameras(cameras: Camera[]): void;
  67247. /**
  67248. * Enables the effect on given cameras
  67249. * @param cameras The camera to enable.
  67250. * @hidden
  67251. */
  67252. _enable(cameras: Camera): void;
  67253. /**
  67254. * Enables the effect on given cameras
  67255. * @param cameras The camera to enable.
  67256. * @hidden
  67257. */
  67258. _enable(cameras: Nullable<Camera[]>): void;
  67259. /**
  67260. * Disables the effect on the given cameras
  67261. * @param cameras The camera to disable.
  67262. * @hidden
  67263. */
  67264. _disable(cameras: Camera): void;
  67265. /**
  67266. * Disables the effect on the given cameras
  67267. * @param cameras The camera to disable.
  67268. * @hidden
  67269. */
  67270. _disable(cameras: Nullable<Camera[]>): void;
  67271. /**
  67272. * Gets a list of the post processes contained in the effect.
  67273. * @param camera The camera to get the post processes on.
  67274. * @returns The list of the post processes in the effect.
  67275. */
  67276. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67277. }
  67278. }
  67279. declare module BABYLON {
  67280. /** @hidden */
  67281. export var extractHighlightsPixelShader: {
  67282. name: string;
  67283. shader: string;
  67284. };
  67285. }
  67286. declare module BABYLON {
  67287. /**
  67288. * 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.
  67289. */
  67290. export class ExtractHighlightsPostProcess extends PostProcess {
  67291. /**
  67292. * The luminance threshold, pixels below this value will be set to black.
  67293. */
  67294. threshold: number;
  67295. /** @hidden */
  67296. _exposure: number;
  67297. /**
  67298. * Post process which has the input texture to be used when performing highlight extraction
  67299. * @hidden
  67300. */
  67301. _inputPostProcess: Nullable<PostProcess>;
  67302. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67303. }
  67304. }
  67305. declare module BABYLON {
  67306. /** @hidden */
  67307. export var bloomMergePixelShader: {
  67308. name: string;
  67309. shader: string;
  67310. };
  67311. }
  67312. declare module BABYLON {
  67313. /**
  67314. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67315. */
  67316. export class BloomMergePostProcess extends PostProcess {
  67317. /** Weight of the bloom to be added to the original input. */
  67318. weight: number;
  67319. /**
  67320. * Creates a new instance of @see BloomMergePostProcess
  67321. * @param name The name of the effect.
  67322. * @param originalFromInput Post process which's input will be used for the merge.
  67323. * @param blurred Blurred highlights post process which's output will be used.
  67324. * @param weight Weight of the bloom to be added to the original input.
  67325. * @param options The required width/height ratio to downsize to before computing the render pass.
  67326. * @param camera The camera to apply the render pass to.
  67327. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67328. * @param engine The engine which the post process will be applied. (default: current engine)
  67329. * @param reusable If the post process can be reused on the same frame. (default: false)
  67330. * @param textureType Type of textures used when performing the post process. (default: 0)
  67331. * @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)
  67332. */
  67333. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67334. /** Weight of the bloom to be added to the original input. */
  67335. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67336. }
  67337. }
  67338. declare module BABYLON {
  67339. /**
  67340. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67341. */
  67342. export class BloomEffect extends PostProcessRenderEffect {
  67343. private bloomScale;
  67344. /**
  67345. * @hidden Internal
  67346. */
  67347. _effects: Array<PostProcess>;
  67348. /**
  67349. * @hidden Internal
  67350. */
  67351. _downscale: ExtractHighlightsPostProcess;
  67352. private _blurX;
  67353. private _blurY;
  67354. private _merge;
  67355. /**
  67356. * The luminance threshold to find bright areas of the image to bloom.
  67357. */
  67358. get threshold(): number;
  67359. set threshold(value: number);
  67360. /**
  67361. * The strength of the bloom.
  67362. */
  67363. get weight(): number;
  67364. set weight(value: number);
  67365. /**
  67366. * Specifies the size of the bloom blur kernel, relative to the final output size
  67367. */
  67368. get kernel(): number;
  67369. set kernel(value: number);
  67370. /**
  67371. * Creates a new instance of @see BloomEffect
  67372. * @param scene The scene the effect belongs to.
  67373. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67374. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67375. * @param bloomWeight The the strength of bloom.
  67376. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67377. * @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)
  67378. */
  67379. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67380. /**
  67381. * Disposes each of the internal effects for a given camera.
  67382. * @param camera The camera to dispose the effect on.
  67383. */
  67384. disposeEffects(camera: Camera): void;
  67385. /**
  67386. * @hidden Internal
  67387. */
  67388. _updateEffects(): void;
  67389. /**
  67390. * Internal
  67391. * @returns if all the contained post processes are ready.
  67392. * @hidden
  67393. */
  67394. _isReady(): boolean;
  67395. }
  67396. }
  67397. declare module BABYLON {
  67398. /** @hidden */
  67399. export var chromaticAberrationPixelShader: {
  67400. name: string;
  67401. shader: string;
  67402. };
  67403. }
  67404. declare module BABYLON {
  67405. /**
  67406. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67407. */
  67408. export class ChromaticAberrationPostProcess extends PostProcess {
  67409. /**
  67410. * The amount of seperation of rgb channels (default: 30)
  67411. */
  67412. aberrationAmount: number;
  67413. /**
  67414. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67415. */
  67416. radialIntensity: number;
  67417. /**
  67418. * 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))
  67419. */
  67420. direction: Vector2;
  67421. /**
  67422. * 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))
  67423. */
  67424. centerPosition: Vector2;
  67425. /**
  67426. * Creates a new instance ChromaticAberrationPostProcess
  67427. * @param name The name of the effect.
  67428. * @param screenWidth The width of the screen to apply the effect on.
  67429. * @param screenHeight The height of the screen to apply the effect on.
  67430. * @param options The required width/height ratio to downsize to before computing the render pass.
  67431. * @param camera The camera to apply the render pass to.
  67432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67433. * @param engine The engine which the post process will be applied. (default: current engine)
  67434. * @param reusable If the post process can be reused on the same frame. (default: false)
  67435. * @param textureType Type of textures used when performing the post process. (default: 0)
  67436. * @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)
  67437. */
  67438. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67439. }
  67440. }
  67441. declare module BABYLON {
  67442. /** @hidden */
  67443. export var circleOfConfusionPixelShader: {
  67444. name: string;
  67445. shader: string;
  67446. };
  67447. }
  67448. declare module BABYLON {
  67449. /**
  67450. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67451. */
  67452. export class CircleOfConfusionPostProcess extends PostProcess {
  67453. /**
  67454. * 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.
  67455. */
  67456. lensSize: number;
  67457. /**
  67458. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67459. */
  67460. fStop: number;
  67461. /**
  67462. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67463. */
  67464. focusDistance: number;
  67465. /**
  67466. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67467. */
  67468. focalLength: number;
  67469. private _depthTexture;
  67470. /**
  67471. * Creates a new instance CircleOfConfusionPostProcess
  67472. * @param name The name of the effect.
  67473. * @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.
  67474. * @param options The required width/height ratio to downsize to before computing the render pass.
  67475. * @param camera The camera to apply the render pass to.
  67476. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67477. * @param engine The engine which the post process will be applied. (default: current engine)
  67478. * @param reusable If the post process can be reused on the same frame. (default: false)
  67479. * @param textureType Type of textures used when performing the post process. (default: 0)
  67480. * @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)
  67481. */
  67482. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67483. /**
  67484. * 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.
  67485. */
  67486. set depthTexture(value: RenderTargetTexture);
  67487. }
  67488. }
  67489. declare module BABYLON {
  67490. /** @hidden */
  67491. export var colorCorrectionPixelShader: {
  67492. name: string;
  67493. shader: string;
  67494. };
  67495. }
  67496. declare module BABYLON {
  67497. /**
  67498. *
  67499. * This post-process allows the modification of rendered colors by using
  67500. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67501. *
  67502. * The object needs to be provided an url to a texture containing the color
  67503. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67504. * Use an image editing software to tweak the LUT to match your needs.
  67505. *
  67506. * For an example of a color LUT, see here:
  67507. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67508. * For explanations on color grading, see here:
  67509. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67510. *
  67511. */
  67512. export class ColorCorrectionPostProcess extends PostProcess {
  67513. private _colorTableTexture;
  67514. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67515. }
  67516. }
  67517. declare module BABYLON {
  67518. /** @hidden */
  67519. export var convolutionPixelShader: {
  67520. name: string;
  67521. shader: string;
  67522. };
  67523. }
  67524. declare module BABYLON {
  67525. /**
  67526. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67527. * input texture to perform effects such as edge detection or sharpening
  67528. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67529. */
  67530. export class ConvolutionPostProcess extends PostProcess {
  67531. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67532. kernel: number[];
  67533. /**
  67534. * Creates a new instance ConvolutionPostProcess
  67535. * @param name The name of the effect.
  67536. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67537. * @param options The required width/height ratio to downsize to before computing the render pass.
  67538. * @param camera The camera to apply the render pass to.
  67539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67540. * @param engine The engine which the post process will be applied. (default: current engine)
  67541. * @param reusable If the post process can be reused on the same frame. (default: false)
  67542. * @param textureType Type of textures used when performing the post process. (default: 0)
  67543. */
  67544. constructor(name: string,
  67545. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67546. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67547. /**
  67548. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67549. */
  67550. static EdgeDetect0Kernel: number[];
  67551. /**
  67552. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67553. */
  67554. static EdgeDetect1Kernel: number[];
  67555. /**
  67556. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67557. */
  67558. static EdgeDetect2Kernel: number[];
  67559. /**
  67560. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67561. */
  67562. static SharpenKernel: number[];
  67563. /**
  67564. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67565. */
  67566. static EmbossKernel: number[];
  67567. /**
  67568. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67569. */
  67570. static GaussianKernel: number[];
  67571. }
  67572. }
  67573. declare module BABYLON {
  67574. /**
  67575. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67576. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67577. * based on samples that have a large difference in distance than the center pixel.
  67578. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67579. */
  67580. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67581. direction: Vector2;
  67582. /**
  67583. * Creates a new instance CircleOfConfusionPostProcess
  67584. * @param name The name of the effect.
  67585. * @param scene The scene the effect belongs to.
  67586. * @param direction The direction the blur should be applied.
  67587. * @param kernel The size of the kernel used to blur.
  67588. * @param options The required width/height ratio to downsize to before computing the render pass.
  67589. * @param camera The camera to apply the render pass to.
  67590. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67591. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67593. * @param engine The engine which the post process will be applied. (default: current engine)
  67594. * @param reusable If the post process can be reused on the same frame. (default: false)
  67595. * @param textureType Type of textures used when performing the post process. (default: 0)
  67596. * @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)
  67597. */
  67598. 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);
  67599. }
  67600. }
  67601. declare module BABYLON {
  67602. /** @hidden */
  67603. export var depthOfFieldMergePixelShader: {
  67604. name: string;
  67605. shader: string;
  67606. };
  67607. }
  67608. declare module BABYLON {
  67609. /**
  67610. * Options to be set when merging outputs from the default pipeline.
  67611. */
  67612. export class DepthOfFieldMergePostProcessOptions {
  67613. /**
  67614. * The original image to merge on top of
  67615. */
  67616. originalFromInput: PostProcess;
  67617. /**
  67618. * Parameters to perform the merge of the depth of field effect
  67619. */
  67620. depthOfField?: {
  67621. circleOfConfusion: PostProcess;
  67622. blurSteps: Array<PostProcess>;
  67623. };
  67624. /**
  67625. * Parameters to perform the merge of bloom effect
  67626. */
  67627. bloom?: {
  67628. blurred: PostProcess;
  67629. weight: number;
  67630. };
  67631. }
  67632. /**
  67633. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67634. */
  67635. export class DepthOfFieldMergePostProcess extends PostProcess {
  67636. private blurSteps;
  67637. /**
  67638. * Creates a new instance of DepthOfFieldMergePostProcess
  67639. * @param name The name of the effect.
  67640. * @param originalFromInput Post process which's input will be used for the merge.
  67641. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67642. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67643. * @param options The required width/height ratio to downsize to before computing the render pass.
  67644. * @param camera The camera to apply the render pass to.
  67645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67646. * @param engine The engine which the post process will be applied. (default: current engine)
  67647. * @param reusable If the post process can be reused on the same frame. (default: false)
  67648. * @param textureType Type of textures used when performing the post process. (default: 0)
  67649. * @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)
  67650. */
  67651. 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);
  67652. /**
  67653. * Updates the effect with the current post process compile time values and recompiles the shader.
  67654. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67655. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67656. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67657. * @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
  67658. * @param onCompiled Called when the shader has been compiled.
  67659. * @param onError Called if there is an error when compiling a shader.
  67660. */
  67661. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67662. }
  67663. }
  67664. declare module BABYLON {
  67665. /**
  67666. * Specifies the level of max blur that should be applied when using the depth of field effect
  67667. */
  67668. export enum DepthOfFieldEffectBlurLevel {
  67669. /**
  67670. * Subtle blur
  67671. */
  67672. Low = 0,
  67673. /**
  67674. * Medium blur
  67675. */
  67676. Medium = 1,
  67677. /**
  67678. * Large blur
  67679. */
  67680. High = 2
  67681. }
  67682. /**
  67683. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67684. */
  67685. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67686. private _circleOfConfusion;
  67687. /**
  67688. * @hidden Internal, blurs from high to low
  67689. */
  67690. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67691. private _depthOfFieldBlurY;
  67692. private _dofMerge;
  67693. /**
  67694. * @hidden Internal post processes in depth of field effect
  67695. */
  67696. _effects: Array<PostProcess>;
  67697. /**
  67698. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67699. */
  67700. set focalLength(value: number);
  67701. get focalLength(): number;
  67702. /**
  67703. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67704. */
  67705. set fStop(value: number);
  67706. get fStop(): number;
  67707. /**
  67708. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67709. */
  67710. set focusDistance(value: number);
  67711. get focusDistance(): number;
  67712. /**
  67713. * 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.
  67714. */
  67715. set lensSize(value: number);
  67716. get lensSize(): number;
  67717. /**
  67718. * Creates a new instance DepthOfFieldEffect
  67719. * @param scene The scene the effect belongs to.
  67720. * @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.
  67721. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67722. * @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)
  67723. */
  67724. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67725. /**
  67726. * Get the current class name of the current effet
  67727. * @returns "DepthOfFieldEffect"
  67728. */
  67729. getClassName(): string;
  67730. /**
  67731. * 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.
  67732. */
  67733. set depthTexture(value: RenderTargetTexture);
  67734. /**
  67735. * Disposes each of the internal effects for a given camera.
  67736. * @param camera The camera to dispose the effect on.
  67737. */
  67738. disposeEffects(camera: Camera): void;
  67739. /**
  67740. * @hidden Internal
  67741. */
  67742. _updateEffects(): void;
  67743. /**
  67744. * Internal
  67745. * @returns if all the contained post processes are ready.
  67746. * @hidden
  67747. */
  67748. _isReady(): boolean;
  67749. }
  67750. }
  67751. declare module BABYLON {
  67752. /** @hidden */
  67753. export var displayPassPixelShader: {
  67754. name: string;
  67755. shader: string;
  67756. };
  67757. }
  67758. declare module BABYLON {
  67759. /**
  67760. * DisplayPassPostProcess which produces an output the same as it's input
  67761. */
  67762. export class DisplayPassPostProcess extends PostProcess {
  67763. /**
  67764. * Creates the DisplayPassPostProcess
  67765. * @param name The name of the effect.
  67766. * @param options The required width/height ratio to downsize to before computing the render pass.
  67767. * @param camera The camera to apply the render pass to.
  67768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67769. * @param engine The engine which the post process will be applied. (default: current engine)
  67770. * @param reusable If the post process can be reused on the same frame. (default: false)
  67771. */
  67772. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67773. }
  67774. }
  67775. declare module BABYLON {
  67776. /** @hidden */
  67777. export var filterPixelShader: {
  67778. name: string;
  67779. shader: string;
  67780. };
  67781. }
  67782. declare module BABYLON {
  67783. /**
  67784. * Applies a kernel filter to the image
  67785. */
  67786. export class FilterPostProcess extends PostProcess {
  67787. /** The matrix to be applied to the image */
  67788. kernelMatrix: Matrix;
  67789. /**
  67790. *
  67791. * @param name The name of the effect.
  67792. * @param kernelMatrix The matrix to be applied to the image
  67793. * @param options The required width/height ratio to downsize to before computing the render pass.
  67794. * @param camera The camera to apply the render pass to.
  67795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67796. * @param engine The engine which the post process will be applied. (default: current engine)
  67797. * @param reusable If the post process can be reused on the same frame. (default: false)
  67798. */
  67799. constructor(name: string,
  67800. /** The matrix to be applied to the image */
  67801. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67802. }
  67803. }
  67804. declare module BABYLON {
  67805. /** @hidden */
  67806. export var fxaaPixelShader: {
  67807. name: string;
  67808. shader: string;
  67809. };
  67810. }
  67811. declare module BABYLON {
  67812. /** @hidden */
  67813. export var fxaaVertexShader: {
  67814. name: string;
  67815. shader: string;
  67816. };
  67817. }
  67818. declare module BABYLON {
  67819. /**
  67820. * Fxaa post process
  67821. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67822. */
  67823. export class FxaaPostProcess extends PostProcess {
  67824. /** @hidden */
  67825. texelWidth: number;
  67826. /** @hidden */
  67827. texelHeight: number;
  67828. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67829. private _getDefines;
  67830. }
  67831. }
  67832. declare module BABYLON {
  67833. /** @hidden */
  67834. export var grainPixelShader: {
  67835. name: string;
  67836. shader: string;
  67837. };
  67838. }
  67839. declare module BABYLON {
  67840. /**
  67841. * The GrainPostProcess adds noise to the image at mid luminance levels
  67842. */
  67843. export class GrainPostProcess extends PostProcess {
  67844. /**
  67845. * The intensity of the grain added (default: 30)
  67846. */
  67847. intensity: number;
  67848. /**
  67849. * If the grain should be randomized on every frame
  67850. */
  67851. animated: boolean;
  67852. /**
  67853. * Creates a new instance of @see GrainPostProcess
  67854. * @param name The name of the effect.
  67855. * @param options The required width/height ratio to downsize to before computing the render pass.
  67856. * @param camera The camera to apply the render pass to.
  67857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67858. * @param engine The engine which the post process will be applied. (default: current engine)
  67859. * @param reusable If the post process can be reused on the same frame. (default: false)
  67860. * @param textureType Type of textures used when performing the post process. (default: 0)
  67861. * @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)
  67862. */
  67863. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67864. }
  67865. }
  67866. declare module BABYLON {
  67867. /** @hidden */
  67868. export var highlightsPixelShader: {
  67869. name: string;
  67870. shader: string;
  67871. };
  67872. }
  67873. declare module BABYLON {
  67874. /**
  67875. * Extracts highlights from the image
  67876. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67877. */
  67878. export class HighlightsPostProcess extends PostProcess {
  67879. /**
  67880. * Extracts highlights from the image
  67881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67882. * @param name The name of the effect.
  67883. * @param options The required width/height ratio to downsize to before computing the render pass.
  67884. * @param camera The camera to apply the render pass to.
  67885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67886. * @param engine The engine which the post process will be applied. (default: current engine)
  67887. * @param reusable If the post process can be reused on the same frame. (default: false)
  67888. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67889. */
  67890. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67891. }
  67892. }
  67893. declare module BABYLON {
  67894. /** @hidden */
  67895. export var mrtFragmentDeclaration: {
  67896. name: string;
  67897. shader: string;
  67898. };
  67899. }
  67900. declare module BABYLON {
  67901. /** @hidden */
  67902. export var geometryPixelShader: {
  67903. name: string;
  67904. shader: string;
  67905. };
  67906. }
  67907. declare module BABYLON {
  67908. /** @hidden */
  67909. export var geometryVertexShader: {
  67910. name: string;
  67911. shader: string;
  67912. };
  67913. }
  67914. declare module BABYLON {
  67915. /** @hidden */
  67916. interface ISavedTransformationMatrix {
  67917. world: Matrix;
  67918. viewProjection: Matrix;
  67919. }
  67920. /**
  67921. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67922. */
  67923. export class GeometryBufferRenderer {
  67924. /**
  67925. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67926. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67927. */
  67928. static readonly POSITION_TEXTURE_TYPE: number;
  67929. /**
  67930. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67931. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67932. */
  67933. static readonly VELOCITY_TEXTURE_TYPE: number;
  67934. /**
  67935. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67936. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67937. */
  67938. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67939. /**
  67940. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67941. * in order to compute objects velocities when enableVelocity is set to "true"
  67942. * @hidden
  67943. */
  67944. _previousTransformationMatrices: {
  67945. [index: number]: ISavedTransformationMatrix;
  67946. };
  67947. /**
  67948. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67949. * in order to compute objects velocities when enableVelocity is set to "true"
  67950. * @hidden
  67951. */
  67952. _previousBonesTransformationMatrices: {
  67953. [index: number]: Float32Array;
  67954. };
  67955. /**
  67956. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67957. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67958. */
  67959. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67960. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67961. renderTransparentMeshes: boolean;
  67962. private _scene;
  67963. private _multiRenderTarget;
  67964. private _ratio;
  67965. private _enablePosition;
  67966. private _enableVelocity;
  67967. private _enableReflectivity;
  67968. private _positionIndex;
  67969. private _velocityIndex;
  67970. private _reflectivityIndex;
  67971. protected _effect: Effect;
  67972. protected _cachedDefines: string;
  67973. /**
  67974. * Set the render list (meshes to be rendered) used in the G buffer.
  67975. */
  67976. set renderList(meshes: Mesh[]);
  67977. /**
  67978. * Gets wether or not G buffer are supported by the running hardware.
  67979. * This requires draw buffer supports
  67980. */
  67981. get isSupported(): boolean;
  67982. /**
  67983. * Returns the index of the given texture type in the G-Buffer textures array
  67984. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67985. * @returns the index of the given texture type in the G-Buffer textures array
  67986. */
  67987. getTextureIndex(textureType: number): number;
  67988. /**
  67989. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67990. */
  67991. get enablePosition(): boolean;
  67992. /**
  67993. * Sets whether or not objects positions are enabled for the G buffer.
  67994. */
  67995. set enablePosition(enable: boolean);
  67996. /**
  67997. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  67998. */
  67999. get enableVelocity(): boolean;
  68000. /**
  68001. * Sets wether or not objects velocities are enabled for the G buffer.
  68002. */
  68003. set enableVelocity(enable: boolean);
  68004. /**
  68005. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68006. */
  68007. get enableReflectivity(): boolean;
  68008. /**
  68009. * Sets wether or not objects roughness are enabled for the G buffer.
  68010. */
  68011. set enableReflectivity(enable: boolean);
  68012. /**
  68013. * Gets the scene associated with the buffer.
  68014. */
  68015. get scene(): Scene;
  68016. /**
  68017. * Gets the ratio used by the buffer during its creation.
  68018. * How big is the buffer related to the main canvas.
  68019. */
  68020. get ratio(): number;
  68021. /** @hidden */
  68022. static _SceneComponentInitialization: (scene: Scene) => void;
  68023. /**
  68024. * Creates a new G Buffer for the scene
  68025. * @param scene The scene the buffer belongs to
  68026. * @param ratio How big is the buffer related to the main canvas.
  68027. */
  68028. constructor(scene: Scene, ratio?: number);
  68029. /**
  68030. * Checks wether everything is ready to render a submesh to the G buffer.
  68031. * @param subMesh the submesh to check readiness for
  68032. * @param useInstances is the mesh drawn using instance or not
  68033. * @returns true if ready otherwise false
  68034. */
  68035. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68036. /**
  68037. * Gets the current underlying G Buffer.
  68038. * @returns the buffer
  68039. */
  68040. getGBuffer(): MultiRenderTarget;
  68041. /**
  68042. * Gets the number of samples used to render the buffer (anti aliasing).
  68043. */
  68044. get samples(): number;
  68045. /**
  68046. * Sets the number of samples used to render the buffer (anti aliasing).
  68047. */
  68048. set samples(value: number);
  68049. /**
  68050. * Disposes the renderer and frees up associated resources.
  68051. */
  68052. dispose(): void;
  68053. protected _createRenderTargets(): void;
  68054. private _copyBonesTransformationMatrices;
  68055. }
  68056. }
  68057. declare module BABYLON {
  68058. interface Scene {
  68059. /** @hidden (Backing field) */
  68060. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68061. /**
  68062. * Gets or Sets the current geometry buffer associated to the scene.
  68063. */
  68064. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68065. /**
  68066. * Enables a GeometryBufferRender and associates it with the scene
  68067. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68068. * @returns the GeometryBufferRenderer
  68069. */
  68070. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68071. /**
  68072. * Disables the GeometryBufferRender associated with the scene
  68073. */
  68074. disableGeometryBufferRenderer(): void;
  68075. }
  68076. /**
  68077. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68078. * in several rendering techniques.
  68079. */
  68080. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68081. /**
  68082. * The component name helpful to identify the component in the list of scene components.
  68083. */
  68084. readonly name: string;
  68085. /**
  68086. * The scene the component belongs to.
  68087. */
  68088. scene: Scene;
  68089. /**
  68090. * Creates a new instance of the component for the given scene
  68091. * @param scene Defines the scene to register the component in
  68092. */
  68093. constructor(scene: Scene);
  68094. /**
  68095. * Registers the component in a given scene
  68096. */
  68097. register(): void;
  68098. /**
  68099. * Rebuilds the elements related to this component in case of
  68100. * context lost for instance.
  68101. */
  68102. rebuild(): void;
  68103. /**
  68104. * Disposes the component and the associated ressources
  68105. */
  68106. dispose(): void;
  68107. private _gatherRenderTargets;
  68108. }
  68109. }
  68110. declare module BABYLON {
  68111. /** @hidden */
  68112. export var motionBlurPixelShader: {
  68113. name: string;
  68114. shader: string;
  68115. };
  68116. }
  68117. declare module BABYLON {
  68118. /**
  68119. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68120. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68121. * As an example, all you have to do is to create the post-process:
  68122. * var mb = new BABYLON.MotionBlurPostProcess(
  68123. * 'mb', // The name of the effect.
  68124. * scene, // The scene containing the objects to blur according to their velocity.
  68125. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68126. * camera // The camera to apply the render pass to.
  68127. * );
  68128. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68129. */
  68130. export class MotionBlurPostProcess extends PostProcess {
  68131. /**
  68132. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68133. */
  68134. motionStrength: number;
  68135. /**
  68136. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68137. */
  68138. get motionBlurSamples(): number;
  68139. /**
  68140. * Sets the number of iterations to be used for motion blur quality
  68141. */
  68142. set motionBlurSamples(samples: number);
  68143. private _motionBlurSamples;
  68144. private _geometryBufferRenderer;
  68145. /**
  68146. * Creates a new instance MotionBlurPostProcess
  68147. * @param name The name of the effect.
  68148. * @param scene The scene containing the objects to blur according to their velocity.
  68149. * @param options The required width/height ratio to downsize to before computing the render pass.
  68150. * @param camera The camera to apply the render pass to.
  68151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68152. * @param engine The engine which the post process will be applied. (default: current engine)
  68153. * @param reusable If the post process can be reused on the same frame. (default: false)
  68154. * @param textureType Type of textures used when performing the post process. (default: 0)
  68155. * @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)
  68156. */
  68157. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68158. /**
  68159. * Excludes the given skinned mesh from computing bones velocities.
  68160. * 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.
  68161. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68162. */
  68163. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68164. /**
  68165. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68166. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68167. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68168. */
  68169. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68170. /**
  68171. * Disposes the post process.
  68172. * @param camera The camera to dispose the post process on.
  68173. */
  68174. dispose(camera?: Camera): void;
  68175. }
  68176. }
  68177. declare module BABYLON {
  68178. /** @hidden */
  68179. export var refractionPixelShader: {
  68180. name: string;
  68181. shader: string;
  68182. };
  68183. }
  68184. declare module BABYLON {
  68185. /**
  68186. * Post process which applies a refractin texture
  68187. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68188. */
  68189. export class RefractionPostProcess extends PostProcess {
  68190. /** the base color of the refraction (used to taint the rendering) */
  68191. color: Color3;
  68192. /** simulated refraction depth */
  68193. depth: number;
  68194. /** the coefficient of the base color (0 to remove base color tainting) */
  68195. colorLevel: number;
  68196. private _refTexture;
  68197. private _ownRefractionTexture;
  68198. /**
  68199. * Gets or sets the refraction texture
  68200. * Please note that you are responsible for disposing the texture if you set it manually
  68201. */
  68202. get refractionTexture(): Texture;
  68203. set refractionTexture(value: Texture);
  68204. /**
  68205. * Initializes the RefractionPostProcess
  68206. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68207. * @param name The name of the effect.
  68208. * @param refractionTextureUrl Url of the refraction texture to use
  68209. * @param color the base color of the refraction (used to taint the rendering)
  68210. * @param depth simulated refraction depth
  68211. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68212. * @param camera The camera to apply the render pass to.
  68213. * @param options The required width/height ratio to downsize to before computing the render pass.
  68214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68215. * @param engine The engine which the post process will be applied. (default: current engine)
  68216. * @param reusable If the post process can be reused on the same frame. (default: false)
  68217. */
  68218. constructor(name: string, refractionTextureUrl: string,
  68219. /** the base color of the refraction (used to taint the rendering) */
  68220. color: Color3,
  68221. /** simulated refraction depth */
  68222. depth: number,
  68223. /** the coefficient of the base color (0 to remove base color tainting) */
  68224. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68225. /**
  68226. * Disposes of the post process
  68227. * @param camera Camera to dispose post process on
  68228. */
  68229. dispose(camera: Camera): void;
  68230. }
  68231. }
  68232. declare module BABYLON {
  68233. /** @hidden */
  68234. export var sharpenPixelShader: {
  68235. name: string;
  68236. shader: string;
  68237. };
  68238. }
  68239. declare module BABYLON {
  68240. /**
  68241. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68242. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68243. */
  68244. export class SharpenPostProcess extends PostProcess {
  68245. /**
  68246. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68247. */
  68248. colorAmount: number;
  68249. /**
  68250. * How much sharpness should be applied (default: 0.3)
  68251. */
  68252. edgeAmount: number;
  68253. /**
  68254. * Creates a new instance ConvolutionPostProcess
  68255. * @param name The name of the effect.
  68256. * @param options The required width/height ratio to downsize to before computing the render pass.
  68257. * @param camera The camera to apply the render pass to.
  68258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68259. * @param engine The engine which the post process will be applied. (default: current engine)
  68260. * @param reusable If the post process can be reused on the same frame. (default: false)
  68261. * @param textureType Type of textures used when performing the post process. (default: 0)
  68262. * @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)
  68263. */
  68264. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68265. }
  68266. }
  68267. declare module BABYLON {
  68268. /**
  68269. * PostProcessRenderPipeline
  68270. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68271. */
  68272. export class PostProcessRenderPipeline {
  68273. private engine;
  68274. private _renderEffects;
  68275. private _renderEffectsForIsolatedPass;
  68276. /**
  68277. * List of inspectable custom properties (used by the Inspector)
  68278. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68279. */
  68280. inspectableCustomProperties: IInspectable[];
  68281. /**
  68282. * @hidden
  68283. */
  68284. protected _cameras: Camera[];
  68285. /** @hidden */
  68286. _name: string;
  68287. /**
  68288. * Gets pipeline name
  68289. */
  68290. get name(): string;
  68291. /** Gets the list of attached cameras */
  68292. get cameras(): Camera[];
  68293. /**
  68294. * Initializes a PostProcessRenderPipeline
  68295. * @param engine engine to add the pipeline to
  68296. * @param name name of the pipeline
  68297. */
  68298. constructor(engine: Engine, name: string);
  68299. /**
  68300. * Gets the class name
  68301. * @returns "PostProcessRenderPipeline"
  68302. */
  68303. getClassName(): string;
  68304. /**
  68305. * If all the render effects in the pipeline are supported
  68306. */
  68307. get isSupported(): boolean;
  68308. /**
  68309. * Adds an effect to the pipeline
  68310. * @param renderEffect the effect to add
  68311. */
  68312. addEffect(renderEffect: PostProcessRenderEffect): void;
  68313. /** @hidden */
  68314. _rebuild(): void;
  68315. /** @hidden */
  68316. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68317. /** @hidden */
  68318. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68319. /** @hidden */
  68320. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68321. /** @hidden */
  68322. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68323. /** @hidden */
  68324. _attachCameras(cameras: Camera, unique: boolean): void;
  68325. /** @hidden */
  68326. _attachCameras(cameras: Camera[], unique: boolean): void;
  68327. /** @hidden */
  68328. _detachCameras(cameras: Camera): void;
  68329. /** @hidden */
  68330. _detachCameras(cameras: Nullable<Camera[]>): void;
  68331. /** @hidden */
  68332. _update(): void;
  68333. /** @hidden */
  68334. _reset(): void;
  68335. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68336. /**
  68337. * Disposes of the pipeline
  68338. */
  68339. dispose(): void;
  68340. }
  68341. }
  68342. declare module BABYLON {
  68343. /**
  68344. * PostProcessRenderPipelineManager class
  68345. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68346. */
  68347. export class PostProcessRenderPipelineManager {
  68348. private _renderPipelines;
  68349. /**
  68350. * Initializes a PostProcessRenderPipelineManager
  68351. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68352. */
  68353. constructor();
  68354. /**
  68355. * Gets the list of supported render pipelines
  68356. */
  68357. get supportedPipelines(): PostProcessRenderPipeline[];
  68358. /**
  68359. * Adds a pipeline to the manager
  68360. * @param renderPipeline The pipeline to add
  68361. */
  68362. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68363. /**
  68364. * Attaches a camera to the pipeline
  68365. * @param renderPipelineName The name of the pipeline to attach to
  68366. * @param cameras the camera to attach
  68367. * @param unique if the camera can be attached multiple times to the pipeline
  68368. */
  68369. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68370. /**
  68371. * Detaches a camera from the pipeline
  68372. * @param renderPipelineName The name of the pipeline to detach from
  68373. * @param cameras the camera to detach
  68374. */
  68375. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68376. /**
  68377. * Enables an effect by name on a pipeline
  68378. * @param renderPipelineName the name of the pipeline to enable the effect in
  68379. * @param renderEffectName the name of the effect to enable
  68380. * @param cameras the cameras that the effect should be enabled on
  68381. */
  68382. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68383. /**
  68384. * Disables an effect by name on a pipeline
  68385. * @param renderPipelineName the name of the pipeline to disable the effect in
  68386. * @param renderEffectName the name of the effect to disable
  68387. * @param cameras the cameras that the effect should be disabled on
  68388. */
  68389. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68390. /**
  68391. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68392. */
  68393. update(): void;
  68394. /** @hidden */
  68395. _rebuild(): void;
  68396. /**
  68397. * Disposes of the manager and pipelines
  68398. */
  68399. dispose(): void;
  68400. }
  68401. }
  68402. declare module BABYLON {
  68403. interface Scene {
  68404. /** @hidden (Backing field) */
  68405. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68406. /**
  68407. * Gets the postprocess render pipeline manager
  68408. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68409. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68410. */
  68411. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68412. }
  68413. /**
  68414. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68415. */
  68416. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68417. /**
  68418. * The component name helpfull to identify the component in the list of scene components.
  68419. */
  68420. readonly name: string;
  68421. /**
  68422. * The scene the component belongs to.
  68423. */
  68424. scene: Scene;
  68425. /**
  68426. * Creates a new instance of the component for the given scene
  68427. * @param scene Defines the scene to register the component in
  68428. */
  68429. constructor(scene: Scene);
  68430. /**
  68431. * Registers the component in a given scene
  68432. */
  68433. register(): void;
  68434. /**
  68435. * Rebuilds the elements related to this component in case of
  68436. * context lost for instance.
  68437. */
  68438. rebuild(): void;
  68439. /**
  68440. * Disposes the component and the associated ressources
  68441. */
  68442. dispose(): void;
  68443. private _gatherRenderTargets;
  68444. }
  68445. }
  68446. declare module BABYLON {
  68447. /**
  68448. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68449. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68450. */
  68451. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68452. private _scene;
  68453. private _camerasToBeAttached;
  68454. /**
  68455. * ID of the sharpen post process,
  68456. */
  68457. private readonly SharpenPostProcessId;
  68458. /**
  68459. * @ignore
  68460. * ID of the image processing post process;
  68461. */
  68462. readonly ImageProcessingPostProcessId: string;
  68463. /**
  68464. * @ignore
  68465. * ID of the Fast Approximate Anti-Aliasing post process;
  68466. */
  68467. readonly FxaaPostProcessId: string;
  68468. /**
  68469. * ID of the chromatic aberration post process,
  68470. */
  68471. private readonly ChromaticAberrationPostProcessId;
  68472. /**
  68473. * ID of the grain post process
  68474. */
  68475. private readonly GrainPostProcessId;
  68476. /**
  68477. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68478. */
  68479. sharpen: SharpenPostProcess;
  68480. private _sharpenEffect;
  68481. private bloom;
  68482. /**
  68483. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68484. */
  68485. depthOfField: DepthOfFieldEffect;
  68486. /**
  68487. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68488. */
  68489. fxaa: FxaaPostProcess;
  68490. /**
  68491. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68492. */
  68493. imageProcessing: ImageProcessingPostProcess;
  68494. /**
  68495. * Chromatic aberration post process which will shift rgb colors in the image
  68496. */
  68497. chromaticAberration: ChromaticAberrationPostProcess;
  68498. private _chromaticAberrationEffect;
  68499. /**
  68500. * Grain post process which add noise to the image
  68501. */
  68502. grain: GrainPostProcess;
  68503. private _grainEffect;
  68504. /**
  68505. * Glow post process which adds a glow to emissive areas of the image
  68506. */
  68507. private _glowLayer;
  68508. /**
  68509. * Animations which can be used to tweak settings over a period of time
  68510. */
  68511. animations: Animation[];
  68512. private _imageProcessingConfigurationObserver;
  68513. private _sharpenEnabled;
  68514. private _bloomEnabled;
  68515. private _depthOfFieldEnabled;
  68516. private _depthOfFieldBlurLevel;
  68517. private _fxaaEnabled;
  68518. private _imageProcessingEnabled;
  68519. private _defaultPipelineTextureType;
  68520. private _bloomScale;
  68521. private _chromaticAberrationEnabled;
  68522. private _grainEnabled;
  68523. private _buildAllowed;
  68524. /**
  68525. * Gets active scene
  68526. */
  68527. get scene(): Scene;
  68528. /**
  68529. * Enable or disable the sharpen process from the pipeline
  68530. */
  68531. set sharpenEnabled(enabled: boolean);
  68532. get sharpenEnabled(): boolean;
  68533. private _resizeObserver;
  68534. private _hardwareScaleLevel;
  68535. private _bloomKernel;
  68536. /**
  68537. * Specifies the size of the bloom blur kernel, relative to the final output size
  68538. */
  68539. get bloomKernel(): number;
  68540. set bloomKernel(value: number);
  68541. /**
  68542. * Specifies the weight of the bloom in the final rendering
  68543. */
  68544. private _bloomWeight;
  68545. /**
  68546. * Specifies the luma threshold for the area that will be blurred by the bloom
  68547. */
  68548. private _bloomThreshold;
  68549. private _hdr;
  68550. /**
  68551. * The strength of the bloom.
  68552. */
  68553. set bloomWeight(value: number);
  68554. get bloomWeight(): number;
  68555. /**
  68556. * The strength of the bloom.
  68557. */
  68558. set bloomThreshold(value: number);
  68559. get bloomThreshold(): number;
  68560. /**
  68561. * The scale of the bloom, lower value will provide better performance.
  68562. */
  68563. set bloomScale(value: number);
  68564. get bloomScale(): number;
  68565. /**
  68566. * Enable or disable the bloom from the pipeline
  68567. */
  68568. set bloomEnabled(enabled: boolean);
  68569. get bloomEnabled(): boolean;
  68570. private _rebuildBloom;
  68571. /**
  68572. * If the depth of field is enabled.
  68573. */
  68574. get depthOfFieldEnabled(): boolean;
  68575. set depthOfFieldEnabled(enabled: boolean);
  68576. /**
  68577. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68578. */
  68579. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68580. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68581. /**
  68582. * If the anti aliasing is enabled.
  68583. */
  68584. set fxaaEnabled(enabled: boolean);
  68585. get fxaaEnabled(): boolean;
  68586. private _samples;
  68587. /**
  68588. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68589. */
  68590. set samples(sampleCount: number);
  68591. get samples(): number;
  68592. /**
  68593. * If image processing is enabled.
  68594. */
  68595. set imageProcessingEnabled(enabled: boolean);
  68596. get imageProcessingEnabled(): boolean;
  68597. /**
  68598. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68599. */
  68600. set glowLayerEnabled(enabled: boolean);
  68601. get glowLayerEnabled(): boolean;
  68602. /**
  68603. * Gets the glow layer (or null if not defined)
  68604. */
  68605. get glowLayer(): Nullable<GlowLayer>;
  68606. /**
  68607. * Enable or disable the chromaticAberration process from the pipeline
  68608. */
  68609. set chromaticAberrationEnabled(enabled: boolean);
  68610. get chromaticAberrationEnabled(): boolean;
  68611. /**
  68612. * Enable or disable the grain process from the pipeline
  68613. */
  68614. set grainEnabled(enabled: boolean);
  68615. get grainEnabled(): boolean;
  68616. /**
  68617. * @constructor
  68618. * @param name - The rendering pipeline name (default: "")
  68619. * @param hdr - If high dynamic range textures should be used (default: true)
  68620. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68621. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68622. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68623. */
  68624. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68625. /**
  68626. * Get the class name
  68627. * @returns "DefaultRenderingPipeline"
  68628. */
  68629. getClassName(): string;
  68630. /**
  68631. * Force the compilation of the entire pipeline.
  68632. */
  68633. prepare(): void;
  68634. private _hasCleared;
  68635. private _prevPostProcess;
  68636. private _prevPrevPostProcess;
  68637. private _setAutoClearAndTextureSharing;
  68638. private _depthOfFieldSceneObserver;
  68639. private _buildPipeline;
  68640. private _disposePostProcesses;
  68641. /**
  68642. * Adds a camera to the pipeline
  68643. * @param camera the camera to be added
  68644. */
  68645. addCamera(camera: Camera): void;
  68646. /**
  68647. * Removes a camera from the pipeline
  68648. * @param camera the camera to remove
  68649. */
  68650. removeCamera(camera: Camera): void;
  68651. /**
  68652. * Dispose of the pipeline and stop all post processes
  68653. */
  68654. dispose(): void;
  68655. /**
  68656. * Serialize the rendering pipeline (Used when exporting)
  68657. * @returns the serialized object
  68658. */
  68659. serialize(): any;
  68660. /**
  68661. * Parse the serialized pipeline
  68662. * @param source Source pipeline.
  68663. * @param scene The scene to load the pipeline to.
  68664. * @param rootUrl The URL of the serialized pipeline.
  68665. * @returns An instantiated pipeline from the serialized object.
  68666. */
  68667. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68668. }
  68669. }
  68670. declare module BABYLON {
  68671. /** @hidden */
  68672. export var lensHighlightsPixelShader: {
  68673. name: string;
  68674. shader: string;
  68675. };
  68676. }
  68677. declare module BABYLON {
  68678. /** @hidden */
  68679. export var depthOfFieldPixelShader: {
  68680. name: string;
  68681. shader: string;
  68682. };
  68683. }
  68684. declare module BABYLON {
  68685. /**
  68686. * BABYLON.JS Chromatic Aberration GLSL Shader
  68687. * Author: Olivier Guyot
  68688. * Separates very slightly R, G and B colors on the edges of the screen
  68689. * Inspired by Francois Tarlier & Martins Upitis
  68690. */
  68691. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68692. /**
  68693. * @ignore
  68694. * The chromatic aberration PostProcess id in the pipeline
  68695. */
  68696. LensChromaticAberrationEffect: string;
  68697. /**
  68698. * @ignore
  68699. * The highlights enhancing PostProcess id in the pipeline
  68700. */
  68701. HighlightsEnhancingEffect: string;
  68702. /**
  68703. * @ignore
  68704. * The depth-of-field PostProcess id in the pipeline
  68705. */
  68706. LensDepthOfFieldEffect: string;
  68707. private _scene;
  68708. private _depthTexture;
  68709. private _grainTexture;
  68710. private _chromaticAberrationPostProcess;
  68711. private _highlightsPostProcess;
  68712. private _depthOfFieldPostProcess;
  68713. private _edgeBlur;
  68714. private _grainAmount;
  68715. private _chromaticAberration;
  68716. private _distortion;
  68717. private _highlightsGain;
  68718. private _highlightsThreshold;
  68719. private _dofDistance;
  68720. private _dofAperture;
  68721. private _dofDarken;
  68722. private _dofPentagon;
  68723. private _blurNoise;
  68724. /**
  68725. * @constructor
  68726. *
  68727. * Effect parameters are as follow:
  68728. * {
  68729. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68730. * edge_blur: number; // from 0 to x (1 for realism)
  68731. * distortion: number; // from 0 to x (1 for realism)
  68732. * grain_amount: number; // from 0 to 1
  68733. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68734. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68735. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68736. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68737. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68738. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68739. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68740. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68741. * }
  68742. * Note: if an effect parameter is unset, effect is disabled
  68743. *
  68744. * @param name The rendering pipeline name
  68745. * @param parameters - An object containing all parameters (see above)
  68746. * @param scene The scene linked to this pipeline
  68747. * @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)
  68748. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68749. */
  68750. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68751. /**
  68752. * Get the class name
  68753. * @returns "LensRenderingPipeline"
  68754. */
  68755. getClassName(): string;
  68756. /**
  68757. * Gets associated scene
  68758. */
  68759. get scene(): Scene;
  68760. /**
  68761. * Gets or sets the edge blur
  68762. */
  68763. get edgeBlur(): number;
  68764. set edgeBlur(value: number);
  68765. /**
  68766. * Gets or sets the grain amount
  68767. */
  68768. get grainAmount(): number;
  68769. set grainAmount(value: number);
  68770. /**
  68771. * Gets or sets the chromatic aberration amount
  68772. */
  68773. get chromaticAberration(): number;
  68774. set chromaticAberration(value: number);
  68775. /**
  68776. * Gets or sets the depth of field aperture
  68777. */
  68778. get dofAperture(): number;
  68779. set dofAperture(value: number);
  68780. /**
  68781. * Gets or sets the edge distortion
  68782. */
  68783. get edgeDistortion(): number;
  68784. set edgeDistortion(value: number);
  68785. /**
  68786. * Gets or sets the depth of field distortion
  68787. */
  68788. get dofDistortion(): number;
  68789. set dofDistortion(value: number);
  68790. /**
  68791. * Gets or sets the darken out of focus amount
  68792. */
  68793. get darkenOutOfFocus(): number;
  68794. set darkenOutOfFocus(value: number);
  68795. /**
  68796. * Gets or sets a boolean indicating if blur noise is enabled
  68797. */
  68798. get blurNoise(): boolean;
  68799. set blurNoise(value: boolean);
  68800. /**
  68801. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68802. */
  68803. get pentagonBokeh(): boolean;
  68804. set pentagonBokeh(value: boolean);
  68805. /**
  68806. * Gets or sets the highlight grain amount
  68807. */
  68808. get highlightsGain(): number;
  68809. set highlightsGain(value: number);
  68810. /**
  68811. * Gets or sets the highlight threshold
  68812. */
  68813. get highlightsThreshold(): number;
  68814. set highlightsThreshold(value: number);
  68815. /**
  68816. * Sets the amount of blur at the edges
  68817. * @param amount blur amount
  68818. */
  68819. setEdgeBlur(amount: number): void;
  68820. /**
  68821. * Sets edge blur to 0
  68822. */
  68823. disableEdgeBlur(): void;
  68824. /**
  68825. * Sets the amout of grain
  68826. * @param amount Amount of grain
  68827. */
  68828. setGrainAmount(amount: number): void;
  68829. /**
  68830. * Set grain amount to 0
  68831. */
  68832. disableGrain(): void;
  68833. /**
  68834. * Sets the chromatic aberration amount
  68835. * @param amount amount of chromatic aberration
  68836. */
  68837. setChromaticAberration(amount: number): void;
  68838. /**
  68839. * Sets chromatic aberration amount to 0
  68840. */
  68841. disableChromaticAberration(): void;
  68842. /**
  68843. * Sets the EdgeDistortion amount
  68844. * @param amount amount of EdgeDistortion
  68845. */
  68846. setEdgeDistortion(amount: number): void;
  68847. /**
  68848. * Sets edge distortion to 0
  68849. */
  68850. disableEdgeDistortion(): void;
  68851. /**
  68852. * Sets the FocusDistance amount
  68853. * @param amount amount of FocusDistance
  68854. */
  68855. setFocusDistance(amount: number): void;
  68856. /**
  68857. * Disables depth of field
  68858. */
  68859. disableDepthOfField(): void;
  68860. /**
  68861. * Sets the Aperture amount
  68862. * @param amount amount of Aperture
  68863. */
  68864. setAperture(amount: number): void;
  68865. /**
  68866. * Sets the DarkenOutOfFocus amount
  68867. * @param amount amount of DarkenOutOfFocus
  68868. */
  68869. setDarkenOutOfFocus(amount: number): void;
  68870. private _pentagonBokehIsEnabled;
  68871. /**
  68872. * Creates a pentagon bokeh effect
  68873. */
  68874. enablePentagonBokeh(): void;
  68875. /**
  68876. * Disables the pentagon bokeh effect
  68877. */
  68878. disablePentagonBokeh(): void;
  68879. /**
  68880. * Enables noise blur
  68881. */
  68882. enableNoiseBlur(): void;
  68883. /**
  68884. * Disables noise blur
  68885. */
  68886. disableNoiseBlur(): void;
  68887. /**
  68888. * Sets the HighlightsGain amount
  68889. * @param amount amount of HighlightsGain
  68890. */
  68891. setHighlightsGain(amount: number): void;
  68892. /**
  68893. * Sets the HighlightsThreshold amount
  68894. * @param amount amount of HighlightsThreshold
  68895. */
  68896. setHighlightsThreshold(amount: number): void;
  68897. /**
  68898. * Disables highlights
  68899. */
  68900. disableHighlights(): void;
  68901. /**
  68902. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68903. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68904. */
  68905. dispose(disableDepthRender?: boolean): void;
  68906. private _createChromaticAberrationPostProcess;
  68907. private _createHighlightsPostProcess;
  68908. private _createDepthOfFieldPostProcess;
  68909. private _createGrainTexture;
  68910. }
  68911. }
  68912. declare module BABYLON {
  68913. /** @hidden */
  68914. export var ssao2PixelShader: {
  68915. name: string;
  68916. shader: string;
  68917. };
  68918. }
  68919. declare module BABYLON {
  68920. /** @hidden */
  68921. export var ssaoCombinePixelShader: {
  68922. name: string;
  68923. shader: string;
  68924. };
  68925. }
  68926. declare module BABYLON {
  68927. /**
  68928. * Render pipeline to produce ssao effect
  68929. */
  68930. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68931. /**
  68932. * @ignore
  68933. * The PassPostProcess id in the pipeline that contains the original scene color
  68934. */
  68935. SSAOOriginalSceneColorEffect: string;
  68936. /**
  68937. * @ignore
  68938. * The SSAO PostProcess id in the pipeline
  68939. */
  68940. SSAORenderEffect: string;
  68941. /**
  68942. * @ignore
  68943. * The horizontal blur PostProcess id in the pipeline
  68944. */
  68945. SSAOBlurHRenderEffect: string;
  68946. /**
  68947. * @ignore
  68948. * The vertical blur PostProcess id in the pipeline
  68949. */
  68950. SSAOBlurVRenderEffect: string;
  68951. /**
  68952. * @ignore
  68953. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68954. */
  68955. SSAOCombineRenderEffect: string;
  68956. /**
  68957. * The output strength of the SSAO post-process. Default value is 1.0.
  68958. */
  68959. totalStrength: number;
  68960. /**
  68961. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  68962. */
  68963. maxZ: number;
  68964. /**
  68965. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  68966. */
  68967. minZAspect: number;
  68968. private _samples;
  68969. /**
  68970. * Number of samples used for the SSAO calculations. Default value is 8
  68971. */
  68972. set samples(n: number);
  68973. get samples(): number;
  68974. private _textureSamples;
  68975. /**
  68976. * Number of samples to use for antialiasing
  68977. */
  68978. set textureSamples(n: number);
  68979. get textureSamples(): number;
  68980. /**
  68981. * Ratio object used for SSAO ratio and blur ratio
  68982. */
  68983. private _ratio;
  68984. /**
  68985. * Dynamically generated sphere sampler.
  68986. */
  68987. private _sampleSphere;
  68988. /**
  68989. * Blur filter offsets
  68990. */
  68991. private _samplerOffsets;
  68992. private _expensiveBlur;
  68993. /**
  68994. * If bilateral blur should be used
  68995. */
  68996. set expensiveBlur(b: boolean);
  68997. get expensiveBlur(): boolean;
  68998. /**
  68999. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69000. */
  69001. radius: number;
  69002. /**
  69003. * The base color of the SSAO post-process
  69004. * The final result is "base + ssao" between [0, 1]
  69005. */
  69006. base: number;
  69007. /**
  69008. * Support test.
  69009. */
  69010. static get IsSupported(): boolean;
  69011. private _scene;
  69012. private _depthTexture;
  69013. private _normalTexture;
  69014. private _randomTexture;
  69015. private _originalColorPostProcess;
  69016. private _ssaoPostProcess;
  69017. private _blurHPostProcess;
  69018. private _blurVPostProcess;
  69019. private _ssaoCombinePostProcess;
  69020. /**
  69021. * Gets active scene
  69022. */
  69023. get scene(): Scene;
  69024. /**
  69025. * @constructor
  69026. * @param name The rendering pipeline name
  69027. * @param scene The scene linked to this pipeline
  69028. * @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 }
  69029. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69030. */
  69031. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69032. /**
  69033. * Get the class name
  69034. * @returns "SSAO2RenderingPipeline"
  69035. */
  69036. getClassName(): string;
  69037. /**
  69038. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69039. */
  69040. dispose(disableGeometryBufferRenderer?: boolean): void;
  69041. private _createBlurPostProcess;
  69042. /** @hidden */
  69043. _rebuild(): void;
  69044. private _bits;
  69045. private _radicalInverse_VdC;
  69046. private _hammersley;
  69047. private _hemisphereSample_uniform;
  69048. private _generateHemisphere;
  69049. private _createSSAOPostProcess;
  69050. private _createSSAOCombinePostProcess;
  69051. private _createRandomTexture;
  69052. /**
  69053. * Serialize the rendering pipeline (Used when exporting)
  69054. * @returns the serialized object
  69055. */
  69056. serialize(): any;
  69057. /**
  69058. * Parse the serialized pipeline
  69059. * @param source Source pipeline.
  69060. * @param scene The scene to load the pipeline to.
  69061. * @param rootUrl The URL of the serialized pipeline.
  69062. * @returns An instantiated pipeline from the serialized object.
  69063. */
  69064. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69065. }
  69066. }
  69067. declare module BABYLON {
  69068. /** @hidden */
  69069. export var ssaoPixelShader: {
  69070. name: string;
  69071. shader: string;
  69072. };
  69073. }
  69074. declare module BABYLON {
  69075. /**
  69076. * Render pipeline to produce ssao effect
  69077. */
  69078. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69079. /**
  69080. * @ignore
  69081. * The PassPostProcess id in the pipeline that contains the original scene color
  69082. */
  69083. SSAOOriginalSceneColorEffect: string;
  69084. /**
  69085. * @ignore
  69086. * The SSAO PostProcess id in the pipeline
  69087. */
  69088. SSAORenderEffect: string;
  69089. /**
  69090. * @ignore
  69091. * The horizontal blur PostProcess id in the pipeline
  69092. */
  69093. SSAOBlurHRenderEffect: string;
  69094. /**
  69095. * @ignore
  69096. * The vertical blur PostProcess id in the pipeline
  69097. */
  69098. SSAOBlurVRenderEffect: string;
  69099. /**
  69100. * @ignore
  69101. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69102. */
  69103. SSAOCombineRenderEffect: string;
  69104. /**
  69105. * The output strength of the SSAO post-process. Default value is 1.0.
  69106. */
  69107. totalStrength: number;
  69108. /**
  69109. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69110. */
  69111. radius: number;
  69112. /**
  69113. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69114. * Must not be equal to fallOff and superior to fallOff.
  69115. * Default value is 0.0075
  69116. */
  69117. area: number;
  69118. /**
  69119. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69120. * Must not be equal to area and inferior to area.
  69121. * Default value is 0.000001
  69122. */
  69123. fallOff: number;
  69124. /**
  69125. * The base color of the SSAO post-process
  69126. * The final result is "base + ssao" between [0, 1]
  69127. */
  69128. base: number;
  69129. private _scene;
  69130. private _depthTexture;
  69131. private _randomTexture;
  69132. private _originalColorPostProcess;
  69133. private _ssaoPostProcess;
  69134. private _blurHPostProcess;
  69135. private _blurVPostProcess;
  69136. private _ssaoCombinePostProcess;
  69137. private _firstUpdate;
  69138. /**
  69139. * Gets active scene
  69140. */
  69141. get scene(): Scene;
  69142. /**
  69143. * @constructor
  69144. * @param name - The rendering pipeline name
  69145. * @param scene - The scene linked to this pipeline
  69146. * @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 }
  69147. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69148. */
  69149. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69150. /**
  69151. * Get the class name
  69152. * @returns "SSAORenderingPipeline"
  69153. */
  69154. getClassName(): string;
  69155. /**
  69156. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69157. */
  69158. dispose(disableDepthRender?: boolean): void;
  69159. private _createBlurPostProcess;
  69160. /** @hidden */
  69161. _rebuild(): void;
  69162. private _createSSAOPostProcess;
  69163. private _createSSAOCombinePostProcess;
  69164. private _createRandomTexture;
  69165. }
  69166. }
  69167. declare module BABYLON {
  69168. /** @hidden */
  69169. export var screenSpaceReflectionPixelShader: {
  69170. name: string;
  69171. shader: string;
  69172. };
  69173. }
  69174. declare module BABYLON {
  69175. /**
  69176. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69177. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69178. */
  69179. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69180. /**
  69181. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69182. */
  69183. threshold: number;
  69184. /**
  69185. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69186. */
  69187. strength: number;
  69188. /**
  69189. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69190. */
  69191. reflectionSpecularFalloffExponent: number;
  69192. /**
  69193. * 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]
  69194. */
  69195. step: number;
  69196. /**
  69197. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69198. */
  69199. roughnessFactor: number;
  69200. private _geometryBufferRenderer;
  69201. private _enableSmoothReflections;
  69202. private _reflectionSamples;
  69203. private _smoothSteps;
  69204. /**
  69205. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69206. * @param name The name of the effect.
  69207. * @param scene The scene containing the objects to calculate reflections.
  69208. * @param options The required width/height ratio to downsize to before computing the render pass.
  69209. * @param camera The camera to apply the render pass to.
  69210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69211. * @param engine The engine which the post process will be applied. (default: current engine)
  69212. * @param reusable If the post process can be reused on the same frame. (default: false)
  69213. * @param textureType Type of textures used when performing the post process. (default: 0)
  69214. * @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)
  69215. */
  69216. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69217. /**
  69218. * Gets wether or not smoothing reflections is enabled.
  69219. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69220. */
  69221. get enableSmoothReflections(): boolean;
  69222. /**
  69223. * Sets wether or not smoothing reflections is enabled.
  69224. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69225. */
  69226. set enableSmoothReflections(enabled: boolean);
  69227. /**
  69228. * Gets the number of samples taken while computing reflections. More samples count is high,
  69229. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69230. */
  69231. get reflectionSamples(): number;
  69232. /**
  69233. * Sets the number of samples taken while computing reflections. More samples count is high,
  69234. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69235. */
  69236. set reflectionSamples(samples: number);
  69237. /**
  69238. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69239. * more the post-process will require GPU power and can generate a drop in FPS.
  69240. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69241. */
  69242. get smoothSteps(): number;
  69243. set smoothSteps(steps: number);
  69244. private _updateEffectDefines;
  69245. }
  69246. }
  69247. declare module BABYLON {
  69248. /** @hidden */
  69249. export var standardPixelShader: {
  69250. name: string;
  69251. shader: string;
  69252. };
  69253. }
  69254. declare module BABYLON {
  69255. /**
  69256. * Standard rendering pipeline
  69257. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69258. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69259. */
  69260. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69261. /**
  69262. * Public members
  69263. */
  69264. /**
  69265. * Post-process which contains the original scene color before the pipeline applies all the effects
  69266. */
  69267. originalPostProcess: Nullable<PostProcess>;
  69268. /**
  69269. * Post-process used to down scale an image x4
  69270. */
  69271. downSampleX4PostProcess: Nullable<PostProcess>;
  69272. /**
  69273. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69274. */
  69275. brightPassPostProcess: Nullable<PostProcess>;
  69276. /**
  69277. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69278. */
  69279. blurHPostProcesses: PostProcess[];
  69280. /**
  69281. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69282. */
  69283. blurVPostProcesses: PostProcess[];
  69284. /**
  69285. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69286. */
  69287. textureAdderPostProcess: Nullable<PostProcess>;
  69288. /**
  69289. * Post-process used to create volumetric lighting effect
  69290. */
  69291. volumetricLightPostProcess: Nullable<PostProcess>;
  69292. /**
  69293. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69294. */
  69295. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69296. /**
  69297. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69298. */
  69299. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69300. /**
  69301. * Post-process used to merge the volumetric light effect and the real scene color
  69302. */
  69303. volumetricLightMergePostProces: Nullable<PostProcess>;
  69304. /**
  69305. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69306. */
  69307. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69308. /**
  69309. * Base post-process used to calculate the average luminance of the final image for HDR
  69310. */
  69311. luminancePostProcess: Nullable<PostProcess>;
  69312. /**
  69313. * Post-processes used to create down sample post-processes in order to get
  69314. * the average luminance of the final image for HDR
  69315. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69316. */
  69317. luminanceDownSamplePostProcesses: PostProcess[];
  69318. /**
  69319. * Post-process used to create a HDR effect (light adaptation)
  69320. */
  69321. hdrPostProcess: Nullable<PostProcess>;
  69322. /**
  69323. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69324. */
  69325. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69326. /**
  69327. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69328. */
  69329. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69330. /**
  69331. * Post-process used to merge the final HDR post-process and the real scene color
  69332. */
  69333. hdrFinalPostProcess: Nullable<PostProcess>;
  69334. /**
  69335. * Post-process used to create a lens flare effect
  69336. */
  69337. lensFlarePostProcess: Nullable<PostProcess>;
  69338. /**
  69339. * Post-process that merges the result of the lens flare post-process and the real scene color
  69340. */
  69341. lensFlareComposePostProcess: Nullable<PostProcess>;
  69342. /**
  69343. * Post-process used to create a motion blur effect
  69344. */
  69345. motionBlurPostProcess: Nullable<PostProcess>;
  69346. /**
  69347. * Post-process used to create a depth of field effect
  69348. */
  69349. depthOfFieldPostProcess: Nullable<PostProcess>;
  69350. /**
  69351. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69352. */
  69353. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69354. /**
  69355. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69356. */
  69357. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69358. /**
  69359. * Represents the brightness threshold in order to configure the illuminated surfaces
  69360. */
  69361. brightThreshold: number;
  69362. /**
  69363. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69364. */
  69365. blurWidth: number;
  69366. /**
  69367. * Sets if the blur for highlighted surfaces must be only horizontal
  69368. */
  69369. horizontalBlur: boolean;
  69370. /**
  69371. * Gets the overall exposure used by the pipeline
  69372. */
  69373. get exposure(): number;
  69374. /**
  69375. * Sets the overall exposure used by the pipeline
  69376. */
  69377. set exposure(value: number);
  69378. /**
  69379. * Texture used typically to simulate "dirty" on camera lens
  69380. */
  69381. lensTexture: Nullable<Texture>;
  69382. /**
  69383. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69384. */
  69385. volumetricLightCoefficient: number;
  69386. /**
  69387. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69388. */
  69389. volumetricLightPower: number;
  69390. /**
  69391. * Used the set the blur intensity to smooth the volumetric lights
  69392. */
  69393. volumetricLightBlurScale: number;
  69394. /**
  69395. * Light (spot or directional) used to generate the volumetric lights rays
  69396. * The source light must have a shadow generate so the pipeline can get its
  69397. * depth map
  69398. */
  69399. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69400. /**
  69401. * For eye adaptation, represents the minimum luminance the eye can see
  69402. */
  69403. hdrMinimumLuminance: number;
  69404. /**
  69405. * For eye adaptation, represents the decrease luminance speed
  69406. */
  69407. hdrDecreaseRate: number;
  69408. /**
  69409. * For eye adaptation, represents the increase luminance speed
  69410. */
  69411. hdrIncreaseRate: number;
  69412. /**
  69413. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69414. */
  69415. get hdrAutoExposure(): boolean;
  69416. /**
  69417. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69418. */
  69419. set hdrAutoExposure(value: boolean);
  69420. /**
  69421. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69422. */
  69423. lensColorTexture: Nullable<Texture>;
  69424. /**
  69425. * The overall strengh for the lens flare effect
  69426. */
  69427. lensFlareStrength: number;
  69428. /**
  69429. * Dispersion coefficient for lens flare ghosts
  69430. */
  69431. lensFlareGhostDispersal: number;
  69432. /**
  69433. * Main lens flare halo width
  69434. */
  69435. lensFlareHaloWidth: number;
  69436. /**
  69437. * Based on the lens distortion effect, defines how much the lens flare result
  69438. * is distorted
  69439. */
  69440. lensFlareDistortionStrength: number;
  69441. /**
  69442. * Configures the blur intensity used for for lens flare (halo)
  69443. */
  69444. lensFlareBlurWidth: number;
  69445. /**
  69446. * Lens star texture must be used to simulate rays on the flares and is available
  69447. * in the documentation
  69448. */
  69449. lensStarTexture: Nullable<Texture>;
  69450. /**
  69451. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69452. * flare effect by taking account of the dirt texture
  69453. */
  69454. lensFlareDirtTexture: Nullable<Texture>;
  69455. /**
  69456. * Represents the focal length for the depth of field effect
  69457. */
  69458. depthOfFieldDistance: number;
  69459. /**
  69460. * Represents the blur intensity for the blurred part of the depth of field effect
  69461. */
  69462. depthOfFieldBlurWidth: number;
  69463. /**
  69464. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69465. */
  69466. get motionStrength(): number;
  69467. /**
  69468. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69469. */
  69470. set motionStrength(strength: number);
  69471. /**
  69472. * Gets wether or not the motion blur post-process is object based or screen based.
  69473. */
  69474. get objectBasedMotionBlur(): boolean;
  69475. /**
  69476. * Sets wether or not the motion blur post-process should be object based or screen based
  69477. */
  69478. set objectBasedMotionBlur(value: boolean);
  69479. /**
  69480. * List of animations for the pipeline (IAnimatable implementation)
  69481. */
  69482. animations: Animation[];
  69483. /**
  69484. * Private members
  69485. */
  69486. private _scene;
  69487. private _currentDepthOfFieldSource;
  69488. private _basePostProcess;
  69489. private _fixedExposure;
  69490. private _currentExposure;
  69491. private _hdrAutoExposure;
  69492. private _hdrCurrentLuminance;
  69493. private _motionStrength;
  69494. private _isObjectBasedMotionBlur;
  69495. private _floatTextureType;
  69496. private _camerasToBeAttached;
  69497. private _ratio;
  69498. private _bloomEnabled;
  69499. private _depthOfFieldEnabled;
  69500. private _vlsEnabled;
  69501. private _lensFlareEnabled;
  69502. private _hdrEnabled;
  69503. private _motionBlurEnabled;
  69504. private _fxaaEnabled;
  69505. private _screenSpaceReflectionsEnabled;
  69506. private _motionBlurSamples;
  69507. private _volumetricLightStepsCount;
  69508. private _samples;
  69509. /**
  69510. * @ignore
  69511. * Specifies if the bloom pipeline is enabled
  69512. */
  69513. get BloomEnabled(): boolean;
  69514. set BloomEnabled(enabled: boolean);
  69515. /**
  69516. * @ignore
  69517. * Specifies if the depth of field pipeline is enabed
  69518. */
  69519. get DepthOfFieldEnabled(): boolean;
  69520. set DepthOfFieldEnabled(enabled: boolean);
  69521. /**
  69522. * @ignore
  69523. * Specifies if the lens flare pipeline is enabed
  69524. */
  69525. get LensFlareEnabled(): boolean;
  69526. set LensFlareEnabled(enabled: boolean);
  69527. /**
  69528. * @ignore
  69529. * Specifies if the HDR pipeline is enabled
  69530. */
  69531. get HDREnabled(): boolean;
  69532. set HDREnabled(enabled: boolean);
  69533. /**
  69534. * @ignore
  69535. * Specifies if the volumetric lights scattering effect is enabled
  69536. */
  69537. get VLSEnabled(): boolean;
  69538. set VLSEnabled(enabled: boolean);
  69539. /**
  69540. * @ignore
  69541. * Specifies if the motion blur effect is enabled
  69542. */
  69543. get MotionBlurEnabled(): boolean;
  69544. set MotionBlurEnabled(enabled: boolean);
  69545. /**
  69546. * Specifies if anti-aliasing is enabled
  69547. */
  69548. get fxaaEnabled(): boolean;
  69549. set fxaaEnabled(enabled: boolean);
  69550. /**
  69551. * Specifies if screen space reflections are enabled.
  69552. */
  69553. get screenSpaceReflectionsEnabled(): boolean;
  69554. set screenSpaceReflectionsEnabled(enabled: boolean);
  69555. /**
  69556. * Specifies the number of steps used to calculate the volumetric lights
  69557. * Typically in interval [50, 200]
  69558. */
  69559. get volumetricLightStepsCount(): number;
  69560. set volumetricLightStepsCount(count: number);
  69561. /**
  69562. * Specifies the number of samples used for the motion blur effect
  69563. * Typically in interval [16, 64]
  69564. */
  69565. get motionBlurSamples(): number;
  69566. set motionBlurSamples(samples: number);
  69567. /**
  69568. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69569. */
  69570. get samples(): number;
  69571. set samples(sampleCount: number);
  69572. /**
  69573. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69574. * @constructor
  69575. * @param name The rendering pipeline name
  69576. * @param scene The scene linked to this pipeline
  69577. * @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)
  69578. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69579. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69580. */
  69581. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69582. private _buildPipeline;
  69583. private _createDownSampleX4PostProcess;
  69584. private _createBrightPassPostProcess;
  69585. private _createBlurPostProcesses;
  69586. private _createTextureAdderPostProcess;
  69587. private _createVolumetricLightPostProcess;
  69588. private _createLuminancePostProcesses;
  69589. private _createHdrPostProcess;
  69590. private _createLensFlarePostProcess;
  69591. private _createDepthOfFieldPostProcess;
  69592. private _createMotionBlurPostProcess;
  69593. private _getDepthTexture;
  69594. private _disposePostProcesses;
  69595. /**
  69596. * Dispose of the pipeline and stop all post processes
  69597. */
  69598. dispose(): void;
  69599. /**
  69600. * Serialize the rendering pipeline (Used when exporting)
  69601. * @returns the serialized object
  69602. */
  69603. serialize(): any;
  69604. /**
  69605. * Parse the serialized pipeline
  69606. * @param source Source pipeline.
  69607. * @param scene The scene to load the pipeline to.
  69608. * @param rootUrl The URL of the serialized pipeline.
  69609. * @returns An instantiated pipeline from the serialized object.
  69610. */
  69611. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69612. /**
  69613. * Luminance steps
  69614. */
  69615. static LuminanceSteps: number;
  69616. }
  69617. }
  69618. declare module BABYLON {
  69619. /** @hidden */
  69620. export var stereoscopicInterlacePixelShader: {
  69621. name: string;
  69622. shader: string;
  69623. };
  69624. }
  69625. declare module BABYLON {
  69626. /**
  69627. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  69628. */
  69629. export class StereoscopicInterlacePostProcessI extends PostProcess {
  69630. private _stepSize;
  69631. private _passedProcess;
  69632. /**
  69633. * Initializes a StereoscopicInterlacePostProcessI
  69634. * @param name The name of the effect.
  69635. * @param rigCameras The rig cameras to be appled to the post process
  69636. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  69637. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  69638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69639. * @param engine The engine which the post process will be applied. (default: current engine)
  69640. * @param reusable If the post process can be reused on the same frame. (default: false)
  69641. */
  69642. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69643. }
  69644. /**
  69645. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  69646. */
  69647. export class StereoscopicInterlacePostProcess extends PostProcess {
  69648. private _stepSize;
  69649. private _passedProcess;
  69650. /**
  69651. * Initializes a StereoscopicInterlacePostProcess
  69652. * @param name The name of the effect.
  69653. * @param rigCameras The rig cameras to be appled to the post process
  69654. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  69655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69656. * @param engine The engine which the post process will be applied. (default: current engine)
  69657. * @param reusable If the post process can be reused on the same frame. (default: false)
  69658. */
  69659. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69660. }
  69661. }
  69662. declare module BABYLON {
  69663. /** @hidden */
  69664. export var tonemapPixelShader: {
  69665. name: string;
  69666. shader: string;
  69667. };
  69668. }
  69669. declare module BABYLON {
  69670. /** Defines operator used for tonemapping */
  69671. export enum TonemappingOperator {
  69672. /** Hable */
  69673. Hable = 0,
  69674. /** Reinhard */
  69675. Reinhard = 1,
  69676. /** HejiDawson */
  69677. HejiDawson = 2,
  69678. /** Photographic */
  69679. Photographic = 3
  69680. }
  69681. /**
  69682. * Defines a post process to apply tone mapping
  69683. */
  69684. export class TonemapPostProcess extends PostProcess {
  69685. private _operator;
  69686. /** Defines the required exposure adjustement */
  69687. exposureAdjustment: number;
  69688. /**
  69689. * Creates a new TonemapPostProcess
  69690. * @param name defines the name of the postprocess
  69691. * @param _operator defines the operator to use
  69692. * @param exposureAdjustment defines the required exposure adjustement
  69693. * @param camera defines the camera to use (can be null)
  69694. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69695. * @param engine defines the hosting engine (can be ignore if camera is set)
  69696. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69697. */
  69698. constructor(name: string, _operator: TonemappingOperator,
  69699. /** Defines the required exposure adjustement */
  69700. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69701. }
  69702. }
  69703. declare module BABYLON {
  69704. /** @hidden */
  69705. export var volumetricLightScatteringPixelShader: {
  69706. name: string;
  69707. shader: string;
  69708. };
  69709. }
  69710. declare module BABYLON {
  69711. /** @hidden */
  69712. export var volumetricLightScatteringPassVertexShader: {
  69713. name: string;
  69714. shader: string;
  69715. };
  69716. }
  69717. declare module BABYLON {
  69718. /** @hidden */
  69719. export var volumetricLightScatteringPassPixelShader: {
  69720. name: string;
  69721. shader: string;
  69722. };
  69723. }
  69724. declare module BABYLON {
  69725. /**
  69726. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69727. */
  69728. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69729. private _volumetricLightScatteringPass;
  69730. private _volumetricLightScatteringRTT;
  69731. private _viewPort;
  69732. private _screenCoordinates;
  69733. private _cachedDefines;
  69734. /**
  69735. * If not undefined, the mesh position is computed from the attached node position
  69736. */
  69737. attachedNode: {
  69738. position: Vector3;
  69739. };
  69740. /**
  69741. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69742. */
  69743. customMeshPosition: Vector3;
  69744. /**
  69745. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69746. */
  69747. useCustomMeshPosition: boolean;
  69748. /**
  69749. * If the post-process should inverse the light scattering direction
  69750. */
  69751. invert: boolean;
  69752. /**
  69753. * The internal mesh used by the post-process
  69754. */
  69755. mesh: Mesh;
  69756. /**
  69757. * @hidden
  69758. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69759. */
  69760. get useDiffuseColor(): boolean;
  69761. set useDiffuseColor(useDiffuseColor: boolean);
  69762. /**
  69763. * Array containing the excluded meshes not rendered in the internal pass
  69764. */
  69765. excludedMeshes: AbstractMesh[];
  69766. /**
  69767. * Controls the overall intensity of the post-process
  69768. */
  69769. exposure: number;
  69770. /**
  69771. * Dissipates each sample's contribution in range [0, 1]
  69772. */
  69773. decay: number;
  69774. /**
  69775. * Controls the overall intensity of each sample
  69776. */
  69777. weight: number;
  69778. /**
  69779. * Controls the density of each sample
  69780. */
  69781. density: number;
  69782. /**
  69783. * @constructor
  69784. * @param name The post-process name
  69785. * @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)
  69786. * @param camera The camera that the post-process will be attached to
  69787. * @param mesh The mesh used to create the light scattering
  69788. * @param samples The post-process quality, default 100
  69789. * @param samplingModeThe post-process filtering mode
  69790. * @param engine The babylon engine
  69791. * @param reusable If the post-process is reusable
  69792. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69793. */
  69794. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69795. /**
  69796. * Returns the string "VolumetricLightScatteringPostProcess"
  69797. * @returns "VolumetricLightScatteringPostProcess"
  69798. */
  69799. getClassName(): string;
  69800. private _isReady;
  69801. /**
  69802. * Sets the new light position for light scattering effect
  69803. * @param position The new custom light position
  69804. */
  69805. setCustomMeshPosition(position: Vector3): void;
  69806. /**
  69807. * Returns the light position for light scattering effect
  69808. * @return Vector3 The custom light position
  69809. */
  69810. getCustomMeshPosition(): Vector3;
  69811. /**
  69812. * Disposes the internal assets and detaches the post-process from the camera
  69813. */
  69814. dispose(camera: Camera): void;
  69815. /**
  69816. * Returns the render target texture used by the post-process
  69817. * @return the render target texture used by the post-process
  69818. */
  69819. getPass(): RenderTargetTexture;
  69820. private _meshExcluded;
  69821. private _createPass;
  69822. private _updateMeshScreenCoordinates;
  69823. /**
  69824. * Creates a default mesh for the Volumeric Light Scattering post-process
  69825. * @param name The mesh name
  69826. * @param scene The scene where to create the mesh
  69827. * @return the default mesh
  69828. */
  69829. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69830. }
  69831. }
  69832. declare module BABYLON {
  69833. interface Scene {
  69834. /** @hidden (Backing field) */
  69835. _boundingBoxRenderer: BoundingBoxRenderer;
  69836. /** @hidden (Backing field) */
  69837. _forceShowBoundingBoxes: boolean;
  69838. /**
  69839. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69840. */
  69841. forceShowBoundingBoxes: boolean;
  69842. /**
  69843. * Gets the bounding box renderer associated with the scene
  69844. * @returns a BoundingBoxRenderer
  69845. */
  69846. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69847. }
  69848. interface AbstractMesh {
  69849. /** @hidden (Backing field) */
  69850. _showBoundingBox: boolean;
  69851. /**
  69852. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69853. */
  69854. showBoundingBox: boolean;
  69855. }
  69856. /**
  69857. * Component responsible of rendering the bounding box of the meshes in a scene.
  69858. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69859. */
  69860. export class BoundingBoxRenderer implements ISceneComponent {
  69861. /**
  69862. * The component name helpfull to identify the component in the list of scene components.
  69863. */
  69864. readonly name: string;
  69865. /**
  69866. * The scene the component belongs to.
  69867. */
  69868. scene: Scene;
  69869. /**
  69870. * Color of the bounding box lines placed in front of an object
  69871. */
  69872. frontColor: Color3;
  69873. /**
  69874. * Color of the bounding box lines placed behind an object
  69875. */
  69876. backColor: Color3;
  69877. /**
  69878. * Defines if the renderer should show the back lines or not
  69879. */
  69880. showBackLines: boolean;
  69881. /**
  69882. * Observable raised before rendering a bounding box
  69883. */
  69884. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  69885. /**
  69886. * Observable raised after rendering a bounding box
  69887. */
  69888. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  69889. /**
  69890. * @hidden
  69891. */
  69892. renderList: SmartArray<BoundingBox>;
  69893. private _colorShader;
  69894. private _vertexBuffers;
  69895. private _indexBuffer;
  69896. private _fillIndexBuffer;
  69897. private _fillIndexData;
  69898. /**
  69899. * Instantiates a new bounding box renderer in a scene.
  69900. * @param scene the scene the renderer renders in
  69901. */
  69902. constructor(scene: Scene);
  69903. /**
  69904. * Registers the component in a given scene
  69905. */
  69906. register(): void;
  69907. private _evaluateSubMesh;
  69908. private _activeMesh;
  69909. private _prepareRessources;
  69910. private _createIndexBuffer;
  69911. /**
  69912. * Rebuilds the elements related to this component in case of
  69913. * context lost for instance.
  69914. */
  69915. rebuild(): void;
  69916. /**
  69917. * @hidden
  69918. */
  69919. reset(): void;
  69920. /**
  69921. * Render the bounding boxes of a specific rendering group
  69922. * @param renderingGroupId defines the rendering group to render
  69923. */
  69924. render(renderingGroupId: number): void;
  69925. /**
  69926. * In case of occlusion queries, we can render the occlusion bounding box through this method
  69927. * @param mesh Define the mesh to render the occlusion bounding box for
  69928. */
  69929. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  69930. /**
  69931. * Dispose and release the resources attached to this renderer.
  69932. */
  69933. dispose(): void;
  69934. }
  69935. }
  69936. declare module BABYLON {
  69937. interface Scene {
  69938. /** @hidden (Backing field) */
  69939. _depthRenderer: {
  69940. [id: string]: DepthRenderer;
  69941. };
  69942. /**
  69943. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69944. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69945. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69946. * @returns the created depth renderer
  69947. */
  69948. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69949. /**
  69950. * Disables a depth renderer for a given camera
  69951. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69952. */
  69953. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69954. }
  69955. /**
  69956. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69957. * in several rendering techniques.
  69958. */
  69959. export class DepthRendererSceneComponent implements ISceneComponent {
  69960. /**
  69961. * The component name helpfull to identify the component in the list of scene components.
  69962. */
  69963. readonly name: string;
  69964. /**
  69965. * The scene the component belongs to.
  69966. */
  69967. scene: Scene;
  69968. /**
  69969. * Creates a new instance of the component for the given scene
  69970. * @param scene Defines the scene to register the component in
  69971. */
  69972. constructor(scene: Scene);
  69973. /**
  69974. * Registers the component in a given scene
  69975. */
  69976. register(): void;
  69977. /**
  69978. * Rebuilds the elements related to this component in case of
  69979. * context lost for instance.
  69980. */
  69981. rebuild(): void;
  69982. /**
  69983. * Disposes the component and the associated ressources
  69984. */
  69985. dispose(): void;
  69986. private _gatherRenderTargets;
  69987. private _gatherActiveCameraRenderTargets;
  69988. }
  69989. }
  69990. declare module BABYLON {
  69991. /** @hidden */
  69992. export var outlinePixelShader: {
  69993. name: string;
  69994. shader: string;
  69995. };
  69996. }
  69997. declare module BABYLON {
  69998. /** @hidden */
  69999. export var outlineVertexShader: {
  70000. name: string;
  70001. shader: string;
  70002. };
  70003. }
  70004. declare module BABYLON {
  70005. interface Scene {
  70006. /** @hidden */
  70007. _outlineRenderer: OutlineRenderer;
  70008. /**
  70009. * Gets the outline renderer associated with the scene
  70010. * @returns a OutlineRenderer
  70011. */
  70012. getOutlineRenderer(): OutlineRenderer;
  70013. }
  70014. interface AbstractMesh {
  70015. /** @hidden (Backing field) */
  70016. _renderOutline: boolean;
  70017. /**
  70018. * Gets or sets a boolean indicating if the outline must be rendered as well
  70019. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70020. */
  70021. renderOutline: boolean;
  70022. /** @hidden (Backing field) */
  70023. _renderOverlay: boolean;
  70024. /**
  70025. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70026. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70027. */
  70028. renderOverlay: boolean;
  70029. }
  70030. /**
  70031. * This class is responsible to draw bothe outline/overlay of meshes.
  70032. * It should not be used directly but through the available method on mesh.
  70033. */
  70034. export class OutlineRenderer implements ISceneComponent {
  70035. /**
  70036. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70037. */
  70038. private static _StencilReference;
  70039. /**
  70040. * The name of the component. Each component must have a unique name.
  70041. */
  70042. name: string;
  70043. /**
  70044. * The scene the component belongs to.
  70045. */
  70046. scene: Scene;
  70047. /**
  70048. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70049. */
  70050. zOffset: number;
  70051. private _engine;
  70052. private _effect;
  70053. private _cachedDefines;
  70054. private _savedDepthWrite;
  70055. /**
  70056. * Instantiates a new outline renderer. (There could be only one per scene).
  70057. * @param scene Defines the scene it belongs to
  70058. */
  70059. constructor(scene: Scene);
  70060. /**
  70061. * Register the component to one instance of a scene.
  70062. */
  70063. register(): void;
  70064. /**
  70065. * Rebuilds the elements related to this component in case of
  70066. * context lost for instance.
  70067. */
  70068. rebuild(): void;
  70069. /**
  70070. * Disposes the component and the associated ressources.
  70071. */
  70072. dispose(): void;
  70073. /**
  70074. * Renders the outline in the canvas.
  70075. * @param subMesh Defines the sumesh to render
  70076. * @param batch Defines the batch of meshes in case of instances
  70077. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70078. */
  70079. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70080. /**
  70081. * Returns whether or not the outline renderer is ready for a given submesh.
  70082. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70083. * @param subMesh Defines the submesh to check readyness for
  70084. * @param useInstances Defines wheter wee are trying to render instances or not
  70085. * @returns true if ready otherwise false
  70086. */
  70087. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70088. private _beforeRenderingMesh;
  70089. private _afterRenderingMesh;
  70090. }
  70091. }
  70092. declare module BABYLON {
  70093. /**
  70094. * Defines the basic options interface of a Sprite Frame Source Size.
  70095. */
  70096. export interface ISpriteJSONSpriteSourceSize {
  70097. /**
  70098. * number of the original width of the Frame
  70099. */
  70100. w: number;
  70101. /**
  70102. * number of the original height of the Frame
  70103. */
  70104. h: number;
  70105. }
  70106. /**
  70107. * Defines the basic options interface of a Sprite Frame Data.
  70108. */
  70109. export interface ISpriteJSONSpriteFrameData {
  70110. /**
  70111. * number of the x offset of the Frame
  70112. */
  70113. x: number;
  70114. /**
  70115. * number of the y offset of the Frame
  70116. */
  70117. y: number;
  70118. /**
  70119. * number of the width of the Frame
  70120. */
  70121. w: number;
  70122. /**
  70123. * number of the height of the Frame
  70124. */
  70125. h: number;
  70126. }
  70127. /**
  70128. * Defines the basic options interface of a JSON Sprite.
  70129. */
  70130. export interface ISpriteJSONSprite {
  70131. /**
  70132. * string name of the Frame
  70133. */
  70134. filename: string;
  70135. /**
  70136. * ISpriteJSONSpriteFrame basic object of the frame data
  70137. */
  70138. frame: ISpriteJSONSpriteFrameData;
  70139. /**
  70140. * boolean to flag is the frame was rotated.
  70141. */
  70142. rotated: boolean;
  70143. /**
  70144. * boolean to flag is the frame was trimmed.
  70145. */
  70146. trimmed: boolean;
  70147. /**
  70148. * ISpriteJSONSpriteFrame basic object of the source data
  70149. */
  70150. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70151. /**
  70152. * ISpriteJSONSpriteFrame basic object of the source data
  70153. */
  70154. sourceSize: ISpriteJSONSpriteSourceSize;
  70155. }
  70156. /**
  70157. * Defines the basic options interface of a JSON atlas.
  70158. */
  70159. export interface ISpriteJSONAtlas {
  70160. /**
  70161. * Array of objects that contain the frame data.
  70162. */
  70163. frames: Array<ISpriteJSONSprite>;
  70164. /**
  70165. * object basic object containing the sprite meta data.
  70166. */
  70167. meta?: object;
  70168. }
  70169. }
  70170. declare module BABYLON {
  70171. /** @hidden */
  70172. export var spriteMapPixelShader: {
  70173. name: string;
  70174. shader: string;
  70175. };
  70176. }
  70177. declare module BABYLON {
  70178. /** @hidden */
  70179. export var spriteMapVertexShader: {
  70180. name: string;
  70181. shader: string;
  70182. };
  70183. }
  70184. declare module BABYLON {
  70185. /**
  70186. * Defines the basic options interface of a SpriteMap
  70187. */
  70188. export interface ISpriteMapOptions {
  70189. /**
  70190. * Vector2 of the number of cells in the grid.
  70191. */
  70192. stageSize?: Vector2;
  70193. /**
  70194. * Vector2 of the size of the output plane in World Units.
  70195. */
  70196. outputSize?: Vector2;
  70197. /**
  70198. * Vector3 of the position of the output plane in World Units.
  70199. */
  70200. outputPosition?: Vector3;
  70201. /**
  70202. * Vector3 of the rotation of the output plane.
  70203. */
  70204. outputRotation?: Vector3;
  70205. /**
  70206. * number of layers that the system will reserve in resources.
  70207. */
  70208. layerCount?: number;
  70209. /**
  70210. * number of max animation frames a single cell will reserve in resources.
  70211. */
  70212. maxAnimationFrames?: number;
  70213. /**
  70214. * number cell index of the base tile when the system compiles.
  70215. */
  70216. baseTile?: number;
  70217. /**
  70218. * boolean flip the sprite after its been repositioned by the framing data.
  70219. */
  70220. flipU?: boolean;
  70221. /**
  70222. * Vector3 scalar of the global RGB values of the SpriteMap.
  70223. */
  70224. colorMultiply?: Vector3;
  70225. }
  70226. /**
  70227. * Defines the IDisposable interface in order to be cleanable from resources.
  70228. */
  70229. export interface ISpriteMap extends IDisposable {
  70230. /**
  70231. * String name of the SpriteMap.
  70232. */
  70233. name: string;
  70234. /**
  70235. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70236. */
  70237. atlasJSON: ISpriteJSONAtlas;
  70238. /**
  70239. * Texture of the SpriteMap.
  70240. */
  70241. spriteSheet: Texture;
  70242. /**
  70243. * The parameters to initialize the SpriteMap with.
  70244. */
  70245. options: ISpriteMapOptions;
  70246. }
  70247. /**
  70248. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70249. */
  70250. export class SpriteMap implements ISpriteMap {
  70251. /** The Name of the spriteMap */
  70252. name: string;
  70253. /** The JSON file with the frame and meta data */
  70254. atlasJSON: ISpriteJSONAtlas;
  70255. /** The systems Sprite Sheet Texture */
  70256. spriteSheet: Texture;
  70257. /** Arguments passed with the Constructor */
  70258. options: ISpriteMapOptions;
  70259. /** Public Sprite Storage array, parsed from atlasJSON */
  70260. sprites: Array<ISpriteJSONSprite>;
  70261. /** Returns the Number of Sprites in the System */
  70262. get spriteCount(): number;
  70263. /** Returns the Position of Output Plane*/
  70264. get position(): Vector3;
  70265. /** Returns the Position of Output Plane*/
  70266. set position(v: Vector3);
  70267. /** Returns the Rotation of Output Plane*/
  70268. get rotation(): Vector3;
  70269. /** Returns the Rotation of Output Plane*/
  70270. set rotation(v: Vector3);
  70271. /** Sets the AnimationMap*/
  70272. get animationMap(): RawTexture;
  70273. /** Sets the AnimationMap*/
  70274. set animationMap(v: RawTexture);
  70275. /** Scene that the SpriteMap was created in */
  70276. private _scene;
  70277. /** Texture Buffer of Float32 that holds tile frame data*/
  70278. private _frameMap;
  70279. /** Texture Buffers of Float32 that holds tileMap data*/
  70280. private _tileMaps;
  70281. /** Texture Buffer of Float32 that holds Animation Data*/
  70282. private _animationMap;
  70283. /** Custom ShaderMaterial Central to the System*/
  70284. private _material;
  70285. /** Custom ShaderMaterial Central to the System*/
  70286. private _output;
  70287. /** Systems Time Ticker*/
  70288. private _time;
  70289. /**
  70290. * Creates a new SpriteMap
  70291. * @param name defines the SpriteMaps Name
  70292. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70293. * @param spriteSheet is the Texture that the Sprites are on.
  70294. * @param options a basic deployment configuration
  70295. * @param scene The Scene that the map is deployed on
  70296. */
  70297. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70298. /**
  70299. * Returns tileID location
  70300. * @returns Vector2 the cell position ID
  70301. */
  70302. getTileID(): Vector2;
  70303. /**
  70304. * Gets the UV location of the mouse over the SpriteMap.
  70305. * @returns Vector2 the UV position of the mouse interaction
  70306. */
  70307. getMousePosition(): Vector2;
  70308. /**
  70309. * Creates the "frame" texture Buffer
  70310. * -------------------------------------
  70311. * Structure of frames
  70312. * "filename": "Falling-Water-2.png",
  70313. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70314. * "rotated": true,
  70315. * "trimmed": true,
  70316. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70317. * "sourceSize": {"w":32,"h":32}
  70318. * @returns RawTexture of the frameMap
  70319. */
  70320. private _createFrameBuffer;
  70321. /**
  70322. * Creates the tileMap texture Buffer
  70323. * @param buffer normally and array of numbers, or a false to generate from scratch
  70324. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70325. * @returns RawTexture of the tileMap
  70326. */
  70327. private _createTileBuffer;
  70328. /**
  70329. * Modifies the data of the tileMaps
  70330. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70331. * @param pos is the iVector2 Coordinates of the Tile
  70332. * @param tile The SpriteIndex of the new Tile
  70333. */
  70334. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70335. /**
  70336. * Creates the animationMap texture Buffer
  70337. * @param buffer normally and array of numbers, or a false to generate from scratch
  70338. * @returns RawTexture of the animationMap
  70339. */
  70340. private _createTileAnimationBuffer;
  70341. /**
  70342. * Modifies the data of the animationMap
  70343. * @param cellID is the Index of the Sprite
  70344. * @param _frame is the target Animation frame
  70345. * @param toCell is the Target Index of the next frame of the animation
  70346. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70347. * @param speed is a global scalar of the time variable on the map.
  70348. */
  70349. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70350. /**
  70351. * Exports the .tilemaps file
  70352. */
  70353. saveTileMaps(): void;
  70354. /**
  70355. * Imports the .tilemaps file
  70356. * @param url of the .tilemaps file
  70357. */
  70358. loadTileMaps(url: string): void;
  70359. /**
  70360. * Release associated resources
  70361. */
  70362. dispose(): void;
  70363. }
  70364. }
  70365. declare module BABYLON {
  70366. /**
  70367. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70368. * @see http://doc.babylonjs.com/babylon101/sprites
  70369. */
  70370. export class SpritePackedManager extends SpriteManager {
  70371. /** defines the packed manager's name */
  70372. name: string;
  70373. /**
  70374. * Creates a new sprite manager from a packed sprite sheet
  70375. * @param name defines the manager's name
  70376. * @param imgUrl defines the sprite sheet url
  70377. * @param capacity defines the maximum allowed number of sprites
  70378. * @param scene defines the hosting scene
  70379. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70380. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70381. * @param samplingMode defines the smapling mode to use with spritesheet
  70382. * @param fromPacked set to true; do not alter
  70383. */
  70384. constructor(
  70385. /** defines the packed manager's name */
  70386. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70387. }
  70388. }
  70389. declare module BABYLON {
  70390. /**
  70391. * Defines the list of states available for a task inside a AssetsManager
  70392. */
  70393. export enum AssetTaskState {
  70394. /**
  70395. * Initialization
  70396. */
  70397. INIT = 0,
  70398. /**
  70399. * Running
  70400. */
  70401. RUNNING = 1,
  70402. /**
  70403. * Done
  70404. */
  70405. DONE = 2,
  70406. /**
  70407. * Error
  70408. */
  70409. ERROR = 3
  70410. }
  70411. /**
  70412. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70413. */
  70414. export abstract class AbstractAssetTask {
  70415. /**
  70416. * Task name
  70417. */ name: string;
  70418. /**
  70419. * Callback called when the task is successful
  70420. */
  70421. onSuccess: (task: any) => void;
  70422. /**
  70423. * Callback called when the task is not successful
  70424. */
  70425. onError: (task: any, message?: string, exception?: any) => void;
  70426. /**
  70427. * Creates a new AssetsManager
  70428. * @param name defines the name of the task
  70429. */
  70430. constructor(
  70431. /**
  70432. * Task name
  70433. */ name: string);
  70434. private _isCompleted;
  70435. private _taskState;
  70436. private _errorObject;
  70437. /**
  70438. * Get if the task is completed
  70439. */
  70440. get isCompleted(): boolean;
  70441. /**
  70442. * Gets the current state of the task
  70443. */
  70444. get taskState(): AssetTaskState;
  70445. /**
  70446. * Gets the current error object (if task is in error)
  70447. */
  70448. get errorObject(): {
  70449. message?: string;
  70450. exception?: any;
  70451. };
  70452. /**
  70453. * Internal only
  70454. * @hidden
  70455. */
  70456. _setErrorObject(message?: string, exception?: any): void;
  70457. /**
  70458. * Execute the current task
  70459. * @param scene defines the scene where you want your assets to be loaded
  70460. * @param onSuccess is a callback called when the task is successfully executed
  70461. * @param onError is a callback called if an error occurs
  70462. */
  70463. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70464. /**
  70465. * Execute the current task
  70466. * @param scene defines the scene where you want your assets to be loaded
  70467. * @param onSuccess is a callback called when the task is successfully executed
  70468. * @param onError is a callback called if an error occurs
  70469. */
  70470. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70471. /**
  70472. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70473. * This can be used with failed tasks that have the reason for failure fixed.
  70474. */
  70475. reset(): void;
  70476. private onErrorCallback;
  70477. private onDoneCallback;
  70478. }
  70479. /**
  70480. * Define the interface used by progress events raised during assets loading
  70481. */
  70482. export interface IAssetsProgressEvent {
  70483. /**
  70484. * Defines the number of remaining tasks to process
  70485. */
  70486. remainingCount: number;
  70487. /**
  70488. * Defines the total number of tasks
  70489. */
  70490. totalCount: number;
  70491. /**
  70492. * Defines the task that was just processed
  70493. */
  70494. task: AbstractAssetTask;
  70495. }
  70496. /**
  70497. * Class used to share progress information about assets loading
  70498. */
  70499. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70500. /**
  70501. * Defines the number of remaining tasks to process
  70502. */
  70503. remainingCount: number;
  70504. /**
  70505. * Defines the total number of tasks
  70506. */
  70507. totalCount: number;
  70508. /**
  70509. * Defines the task that was just processed
  70510. */
  70511. task: AbstractAssetTask;
  70512. /**
  70513. * Creates a AssetsProgressEvent
  70514. * @param remainingCount defines the number of remaining tasks to process
  70515. * @param totalCount defines the total number of tasks
  70516. * @param task defines the task that was just processed
  70517. */
  70518. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70519. }
  70520. /**
  70521. * Define a task used by AssetsManager to load meshes
  70522. */
  70523. export class MeshAssetTask extends AbstractAssetTask {
  70524. /**
  70525. * Defines the name of the task
  70526. */
  70527. name: string;
  70528. /**
  70529. * Defines the list of mesh's names you want to load
  70530. */
  70531. meshesNames: any;
  70532. /**
  70533. * Defines the root url to use as a base to load your meshes and associated resources
  70534. */
  70535. rootUrl: string;
  70536. /**
  70537. * Defines the filename or File of the scene to load from
  70538. */
  70539. sceneFilename: string | File;
  70540. /**
  70541. * Gets the list of loaded meshes
  70542. */
  70543. loadedMeshes: Array<AbstractMesh>;
  70544. /**
  70545. * Gets the list of loaded particle systems
  70546. */
  70547. loadedParticleSystems: Array<IParticleSystem>;
  70548. /**
  70549. * Gets the list of loaded skeletons
  70550. */
  70551. loadedSkeletons: Array<Skeleton>;
  70552. /**
  70553. * Gets the list of loaded animation groups
  70554. */
  70555. loadedAnimationGroups: Array<AnimationGroup>;
  70556. /**
  70557. * Callback called when the task is successful
  70558. */
  70559. onSuccess: (task: MeshAssetTask) => void;
  70560. /**
  70561. * Callback called when the task is successful
  70562. */
  70563. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70564. /**
  70565. * Creates a new MeshAssetTask
  70566. * @param name defines the name of the task
  70567. * @param meshesNames defines the list of mesh's names you want to load
  70568. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70569. * @param sceneFilename defines the filename or File of the scene to load from
  70570. */
  70571. constructor(
  70572. /**
  70573. * Defines the name of the task
  70574. */
  70575. name: string,
  70576. /**
  70577. * Defines the list of mesh's names you want to load
  70578. */
  70579. meshesNames: any,
  70580. /**
  70581. * Defines the root url to use as a base to load your meshes and associated resources
  70582. */
  70583. rootUrl: string,
  70584. /**
  70585. * Defines the filename or File of the scene to load from
  70586. */
  70587. sceneFilename: string | File);
  70588. /**
  70589. * Execute the current task
  70590. * @param scene defines the scene where you want your assets to be loaded
  70591. * @param onSuccess is a callback called when the task is successfully executed
  70592. * @param onError is a callback called if an error occurs
  70593. */
  70594. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70595. }
  70596. /**
  70597. * Define a task used by AssetsManager to load text content
  70598. */
  70599. export class TextFileAssetTask extends AbstractAssetTask {
  70600. /**
  70601. * Defines the name of the task
  70602. */
  70603. name: string;
  70604. /**
  70605. * Defines the location of the file to load
  70606. */
  70607. url: string;
  70608. /**
  70609. * Gets the loaded text string
  70610. */
  70611. text: string;
  70612. /**
  70613. * Callback called when the task is successful
  70614. */
  70615. onSuccess: (task: TextFileAssetTask) => void;
  70616. /**
  70617. * Callback called when the task is successful
  70618. */
  70619. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70620. /**
  70621. * Creates a new TextFileAssetTask object
  70622. * @param name defines the name of the task
  70623. * @param url defines the location of the file to load
  70624. */
  70625. constructor(
  70626. /**
  70627. * Defines the name of the task
  70628. */
  70629. name: string,
  70630. /**
  70631. * Defines the location of the file to load
  70632. */
  70633. url: string);
  70634. /**
  70635. * Execute the current task
  70636. * @param scene defines the scene where you want your assets to be loaded
  70637. * @param onSuccess is a callback called when the task is successfully executed
  70638. * @param onError is a callback called if an error occurs
  70639. */
  70640. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70641. }
  70642. /**
  70643. * Define a task used by AssetsManager to load binary data
  70644. */
  70645. export class BinaryFileAssetTask extends AbstractAssetTask {
  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. * Gets the lodaded data (as an array buffer)
  70656. */
  70657. data: ArrayBuffer;
  70658. /**
  70659. * Callback called when the task is successful
  70660. */
  70661. onSuccess: (task: BinaryFileAssetTask) => void;
  70662. /**
  70663. * Callback called when the task is successful
  70664. */
  70665. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70666. /**
  70667. * Creates a new BinaryFileAssetTask object
  70668. * @param name defines the name of the new task
  70669. * @param url defines the location of the file to load
  70670. */
  70671. constructor(
  70672. /**
  70673. * Defines the name of the task
  70674. */
  70675. name: string,
  70676. /**
  70677. * Defines the location of the file to load
  70678. */
  70679. url: string);
  70680. /**
  70681. * Execute the current task
  70682. * @param scene defines the scene where you want your assets to be loaded
  70683. * @param onSuccess is a callback called when the task is successfully executed
  70684. * @param onError is a callback called if an error occurs
  70685. */
  70686. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70687. }
  70688. /**
  70689. * Define a task used by AssetsManager to load images
  70690. */
  70691. export class ImageAssetTask extends AbstractAssetTask {
  70692. /**
  70693. * Defines the name of the task
  70694. */
  70695. name: string;
  70696. /**
  70697. * Defines the location of the image to load
  70698. */
  70699. url: string;
  70700. /**
  70701. * Gets the loaded images
  70702. */
  70703. image: HTMLImageElement;
  70704. /**
  70705. * Callback called when the task is successful
  70706. */
  70707. onSuccess: (task: ImageAssetTask) => void;
  70708. /**
  70709. * Callback called when the task is successful
  70710. */
  70711. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70712. /**
  70713. * Creates a new ImageAssetTask
  70714. * @param name defines the name of the task
  70715. * @param url defines the location of the image to load
  70716. */
  70717. constructor(
  70718. /**
  70719. * Defines the name of the task
  70720. */
  70721. name: string,
  70722. /**
  70723. * Defines the location of the image to load
  70724. */
  70725. url: string);
  70726. /**
  70727. * Execute the current task
  70728. * @param scene defines the scene where you want your assets to be loaded
  70729. * @param onSuccess is a callback called when the task is successfully executed
  70730. * @param onError is a callback called if an error occurs
  70731. */
  70732. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70733. }
  70734. /**
  70735. * Defines the interface used by texture loading tasks
  70736. */
  70737. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70738. /**
  70739. * Gets the loaded texture
  70740. */
  70741. texture: TEX;
  70742. }
  70743. /**
  70744. * Define a task used by AssetsManager to load 2D textures
  70745. */
  70746. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70747. /**
  70748. * Defines the name of the task
  70749. */
  70750. name: string;
  70751. /**
  70752. * Defines the location of the file to load
  70753. */
  70754. url: string;
  70755. /**
  70756. * Defines if mipmap should not be generated (default is false)
  70757. */
  70758. noMipmap?: boolean | undefined;
  70759. /**
  70760. * Defines if texture must be inverted on Y axis (default is true)
  70761. */
  70762. invertY: boolean;
  70763. /**
  70764. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70765. */
  70766. samplingMode: number;
  70767. /**
  70768. * Gets the loaded texture
  70769. */
  70770. texture: Texture;
  70771. /**
  70772. * Callback called when the task is successful
  70773. */
  70774. onSuccess: (task: TextureAssetTask) => void;
  70775. /**
  70776. * Callback called when the task is successful
  70777. */
  70778. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70779. /**
  70780. * Creates a new TextureAssetTask object
  70781. * @param name defines the name of the task
  70782. * @param url defines the location of the file to load
  70783. * @param noMipmap defines if mipmap should not be generated (default is false)
  70784. * @param invertY defines if texture must be inverted on Y axis (default is true)
  70785. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70786. */
  70787. constructor(
  70788. /**
  70789. * Defines the name of the task
  70790. */
  70791. name: string,
  70792. /**
  70793. * Defines the location of the file to load
  70794. */
  70795. url: string,
  70796. /**
  70797. * Defines if mipmap should not be generated (default is false)
  70798. */
  70799. noMipmap?: boolean | undefined,
  70800. /**
  70801. * Defines if texture must be inverted on Y axis (default is true)
  70802. */
  70803. invertY?: boolean,
  70804. /**
  70805. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70806. */
  70807. samplingMode?: number);
  70808. /**
  70809. * Execute the current task
  70810. * @param scene defines the scene where you want your assets to be loaded
  70811. * @param onSuccess is a callback called when the task is successfully executed
  70812. * @param onError is a callback called if an error occurs
  70813. */
  70814. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70815. }
  70816. /**
  70817. * Define a task used by AssetsManager to load cube textures
  70818. */
  70819. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  70820. /**
  70821. * Defines the name of the task
  70822. */
  70823. name: string;
  70824. /**
  70825. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70826. */
  70827. url: string;
  70828. /**
  70829. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70830. */
  70831. extensions?: string[] | undefined;
  70832. /**
  70833. * Defines if mipmaps should not be generated (default is false)
  70834. */
  70835. noMipmap?: boolean | undefined;
  70836. /**
  70837. * Defines the explicit list of files (undefined by default)
  70838. */
  70839. files?: string[] | undefined;
  70840. /**
  70841. * Gets the loaded texture
  70842. */
  70843. texture: CubeTexture;
  70844. /**
  70845. * Callback called when the task is successful
  70846. */
  70847. onSuccess: (task: CubeTextureAssetTask) => void;
  70848. /**
  70849. * Callback called when the task is successful
  70850. */
  70851. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  70852. /**
  70853. * Creates a new CubeTextureAssetTask
  70854. * @param name defines the name of the task
  70855. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70856. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70857. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70858. * @param files defines the explicit list of files (undefined by default)
  70859. */
  70860. constructor(
  70861. /**
  70862. * Defines the name of the task
  70863. */
  70864. name: string,
  70865. /**
  70866. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70867. */
  70868. url: string,
  70869. /**
  70870. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70871. */
  70872. extensions?: string[] | undefined,
  70873. /**
  70874. * Defines if mipmaps should not be generated (default is false)
  70875. */
  70876. noMipmap?: boolean | undefined,
  70877. /**
  70878. * Defines the explicit list of files (undefined by default)
  70879. */
  70880. files?: string[] | undefined);
  70881. /**
  70882. * Execute the current task
  70883. * @param scene defines the scene where you want your assets to be loaded
  70884. * @param onSuccess is a callback called when the task is successfully executed
  70885. * @param onError is a callback called if an error occurs
  70886. */
  70887. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70888. }
  70889. /**
  70890. * Define a task used by AssetsManager to load HDR cube textures
  70891. */
  70892. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70893. /**
  70894. * Defines the name of the task
  70895. */
  70896. name: string;
  70897. /**
  70898. * Defines the location of the file to load
  70899. */
  70900. url: string;
  70901. /**
  70902. * Defines the desired size (the more it increases the longer the generation will be)
  70903. */
  70904. size: number;
  70905. /**
  70906. * Defines if mipmaps should not be generated (default is false)
  70907. */
  70908. noMipmap: boolean;
  70909. /**
  70910. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70911. */
  70912. generateHarmonics: boolean;
  70913. /**
  70914. * 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)
  70915. */
  70916. gammaSpace: boolean;
  70917. /**
  70918. * Internal Use Only
  70919. */
  70920. reserved: boolean;
  70921. /**
  70922. * Gets the loaded texture
  70923. */
  70924. texture: HDRCubeTexture;
  70925. /**
  70926. * Callback called when the task is successful
  70927. */
  70928. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70929. /**
  70930. * Callback called when the task is successful
  70931. */
  70932. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70933. /**
  70934. * Creates a new HDRCubeTextureAssetTask object
  70935. * @param name defines the name of the task
  70936. * @param url defines the location of the file to load
  70937. * @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.
  70938. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70939. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70940. * @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)
  70941. * @param reserved Internal use only
  70942. */
  70943. constructor(
  70944. /**
  70945. * Defines the name of the task
  70946. */
  70947. name: string,
  70948. /**
  70949. * Defines the location of the file to load
  70950. */
  70951. url: string,
  70952. /**
  70953. * Defines the desired size (the more it increases the longer the generation will be)
  70954. */
  70955. size: number,
  70956. /**
  70957. * Defines if mipmaps should not be generated (default is false)
  70958. */
  70959. noMipmap?: boolean,
  70960. /**
  70961. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70962. */
  70963. generateHarmonics?: boolean,
  70964. /**
  70965. * 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)
  70966. */
  70967. gammaSpace?: boolean,
  70968. /**
  70969. * Internal Use Only
  70970. */
  70971. reserved?: boolean);
  70972. /**
  70973. * Execute the current task
  70974. * @param scene defines the scene where you want your assets to be loaded
  70975. * @param onSuccess is a callback called when the task is successfully executed
  70976. * @param onError is a callback called if an error occurs
  70977. */
  70978. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70979. }
  70980. /**
  70981. * Define a task used by AssetsManager to load Equirectangular cube textures
  70982. */
  70983. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70984. /**
  70985. * Defines the name of the task
  70986. */
  70987. name: string;
  70988. /**
  70989. * Defines the location of the file to load
  70990. */
  70991. url: string;
  70992. /**
  70993. * Defines the desired size (the more it increases the longer the generation will be)
  70994. */
  70995. size: number;
  70996. /**
  70997. * Defines if mipmaps should not be generated (default is false)
  70998. */
  70999. noMipmap: boolean;
  71000. /**
  71001. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71002. * but the standard material would require them in Gamma space) (default is true)
  71003. */
  71004. gammaSpace: boolean;
  71005. /**
  71006. * Gets the loaded texture
  71007. */
  71008. texture: EquiRectangularCubeTexture;
  71009. /**
  71010. * Callback called when the task is successful
  71011. */
  71012. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71013. /**
  71014. * Callback called when the task is successful
  71015. */
  71016. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71017. /**
  71018. * Creates a new EquiRectangularCubeTextureAssetTask object
  71019. * @param name defines the name of the task
  71020. * @param url defines the location of the file to load
  71021. * @param size defines the desired size (the more it increases the longer the generation will be)
  71022. * If the size is omitted this implies you are using a preprocessed cubemap.
  71023. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71024. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71025. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71026. * (default is true)
  71027. */
  71028. constructor(
  71029. /**
  71030. * Defines the name of the task
  71031. */
  71032. name: string,
  71033. /**
  71034. * Defines the location of the file to load
  71035. */
  71036. url: string,
  71037. /**
  71038. * Defines the desired size (the more it increases the longer the generation will be)
  71039. */
  71040. size: number,
  71041. /**
  71042. * Defines if mipmaps should not be generated (default is false)
  71043. */
  71044. noMipmap?: boolean,
  71045. /**
  71046. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71047. * but the standard material would require them in Gamma space) (default is true)
  71048. */
  71049. gammaSpace?: boolean);
  71050. /**
  71051. * Execute the current task
  71052. * @param scene defines the scene where you want your assets to be loaded
  71053. * @param onSuccess is a callback called when the task is successfully executed
  71054. * @param onError is a callback called if an error occurs
  71055. */
  71056. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71057. }
  71058. /**
  71059. * This class can be used to easily import assets into a scene
  71060. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71061. */
  71062. export class AssetsManager {
  71063. private _scene;
  71064. private _isLoading;
  71065. protected _tasks: AbstractAssetTask[];
  71066. protected _waitingTasksCount: number;
  71067. protected _totalTasksCount: number;
  71068. /**
  71069. * Callback called when all tasks are processed
  71070. */
  71071. onFinish: (tasks: AbstractAssetTask[]) => void;
  71072. /**
  71073. * Callback called when a task is successful
  71074. */
  71075. onTaskSuccess: (task: AbstractAssetTask) => void;
  71076. /**
  71077. * Callback called when a task had an error
  71078. */
  71079. onTaskError: (task: AbstractAssetTask) => void;
  71080. /**
  71081. * Callback called when a task is done (whatever the result is)
  71082. */
  71083. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71084. /**
  71085. * Observable called when all tasks are processed
  71086. */
  71087. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71088. /**
  71089. * Observable called when a task had an error
  71090. */
  71091. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71092. /**
  71093. * Observable called when all tasks were executed
  71094. */
  71095. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71096. /**
  71097. * Observable called when a task is done (whatever the result is)
  71098. */
  71099. onProgressObservable: Observable<IAssetsProgressEvent>;
  71100. /**
  71101. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71102. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71103. */
  71104. useDefaultLoadingScreen: boolean;
  71105. /**
  71106. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71107. * when all assets have been downloaded.
  71108. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71109. */
  71110. autoHideLoadingUI: boolean;
  71111. /**
  71112. * Creates a new AssetsManager
  71113. * @param scene defines the scene to work on
  71114. */
  71115. constructor(scene: Scene);
  71116. /**
  71117. * Add a MeshAssetTask to the list of active tasks
  71118. * @param taskName defines the name of the new task
  71119. * @param meshesNames defines the name of meshes to load
  71120. * @param rootUrl defines the root url to use to locate files
  71121. * @param sceneFilename defines the filename of the scene file
  71122. * @returns a new MeshAssetTask object
  71123. */
  71124. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71125. /**
  71126. * Add a TextFileAssetTask to the list of active tasks
  71127. * @param taskName defines the name of the new task
  71128. * @param url defines the url of the file to load
  71129. * @returns a new TextFileAssetTask object
  71130. */
  71131. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71132. /**
  71133. * Add a BinaryFileAssetTask to the list of active tasks
  71134. * @param taskName defines the name of the new task
  71135. * @param url defines the url of the file to load
  71136. * @returns a new BinaryFileAssetTask object
  71137. */
  71138. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71139. /**
  71140. * Add a ImageAssetTask to the list of active tasks
  71141. * @param taskName defines the name of the new task
  71142. * @param url defines the url of the file to load
  71143. * @returns a new ImageAssetTask object
  71144. */
  71145. addImageTask(taskName: string, url: string): ImageAssetTask;
  71146. /**
  71147. * Add a TextureAssetTask to the list of active tasks
  71148. * @param taskName defines the name of the new task
  71149. * @param url defines the url of the file to load
  71150. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71151. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71152. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71153. * @returns a new TextureAssetTask object
  71154. */
  71155. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71156. /**
  71157. * Add a CubeTextureAssetTask to the list of active tasks
  71158. * @param taskName defines the name of the new task
  71159. * @param url defines the url of the file to load
  71160. * @param extensions defines the extension to use to load the cube map (can be null)
  71161. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71162. * @param files defines the list of files to load (can be null)
  71163. * @returns a new CubeTextureAssetTask object
  71164. */
  71165. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71166. /**
  71167. *
  71168. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71169. * @param taskName defines the name of the new task
  71170. * @param url defines the url of the file to load
  71171. * @param size defines the size you want for the cubemap (can be null)
  71172. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71173. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71174. * @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)
  71175. * @param reserved Internal use only
  71176. * @returns a new HDRCubeTextureAssetTask object
  71177. */
  71178. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71179. /**
  71180. *
  71181. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71182. * @param taskName defines the name of the new task
  71183. * @param url defines the url of the file to load
  71184. * @param size defines the size you want for the cubemap (can be null)
  71185. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71186. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71187. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71188. * @returns a new EquiRectangularCubeTextureAssetTask object
  71189. */
  71190. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71191. /**
  71192. * Remove a task from the assets manager.
  71193. * @param task the task to remove
  71194. */
  71195. removeTask(task: AbstractAssetTask): void;
  71196. private _decreaseWaitingTasksCount;
  71197. private _runTask;
  71198. /**
  71199. * Reset the AssetsManager and remove all tasks
  71200. * @return the current instance of the AssetsManager
  71201. */
  71202. reset(): AssetsManager;
  71203. /**
  71204. * Start the loading process
  71205. * @return the current instance of the AssetsManager
  71206. */
  71207. load(): AssetsManager;
  71208. /**
  71209. * Start the loading process as an async operation
  71210. * @return a promise returning the list of failed tasks
  71211. */
  71212. loadAsync(): Promise<void>;
  71213. }
  71214. }
  71215. declare module BABYLON {
  71216. /**
  71217. * Wrapper class for promise with external resolve and reject.
  71218. */
  71219. export class Deferred<T> {
  71220. /**
  71221. * The promise associated with this deferred object.
  71222. */
  71223. readonly promise: Promise<T>;
  71224. private _resolve;
  71225. private _reject;
  71226. /**
  71227. * The resolve method of the promise associated with this deferred object.
  71228. */
  71229. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71230. /**
  71231. * The reject method of the promise associated with this deferred object.
  71232. */
  71233. get reject(): (reason?: any) => void;
  71234. /**
  71235. * Constructor for this deferred object.
  71236. */
  71237. constructor();
  71238. }
  71239. }
  71240. declare module BABYLON {
  71241. /**
  71242. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71243. */
  71244. export class MeshExploder {
  71245. private _centerMesh;
  71246. private _meshes;
  71247. private _meshesOrigins;
  71248. private _toCenterVectors;
  71249. private _scaledDirection;
  71250. private _newPosition;
  71251. private _centerPosition;
  71252. /**
  71253. * Explodes meshes from a center mesh.
  71254. * @param meshes The meshes to explode.
  71255. * @param centerMesh The mesh to be center of explosion.
  71256. */
  71257. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71258. private _setCenterMesh;
  71259. /**
  71260. * Get class name
  71261. * @returns "MeshExploder"
  71262. */
  71263. getClassName(): string;
  71264. /**
  71265. * "Exploded meshes"
  71266. * @returns Array of meshes with the centerMesh at index 0.
  71267. */
  71268. getMeshes(): Array<Mesh>;
  71269. /**
  71270. * Explodes meshes giving a specific direction
  71271. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71272. */
  71273. explode(direction?: number): void;
  71274. }
  71275. }
  71276. declare module BABYLON {
  71277. /**
  71278. * Class used to help managing file picking and drag'n'drop
  71279. */
  71280. export class FilesInput {
  71281. /**
  71282. * List of files ready to be loaded
  71283. */
  71284. static get FilesToLoad(): {
  71285. [key: string]: File;
  71286. };
  71287. /**
  71288. * Callback called when a file is processed
  71289. */
  71290. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71291. private _engine;
  71292. private _currentScene;
  71293. private _sceneLoadedCallback;
  71294. private _progressCallback;
  71295. private _additionalRenderLoopLogicCallback;
  71296. private _textureLoadingCallback;
  71297. private _startingProcessingFilesCallback;
  71298. private _onReloadCallback;
  71299. private _errorCallback;
  71300. private _elementToMonitor;
  71301. private _sceneFileToLoad;
  71302. private _filesToLoad;
  71303. /**
  71304. * Creates a new FilesInput
  71305. * @param engine defines the rendering engine
  71306. * @param scene defines the hosting scene
  71307. * @param sceneLoadedCallback callback called when scene is loaded
  71308. * @param progressCallback callback called to track progress
  71309. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71310. * @param textureLoadingCallback callback called when a texture is loading
  71311. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71312. * @param onReloadCallback callback called when a reload is requested
  71313. * @param errorCallback callback call if an error occurs
  71314. */
  71315. 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);
  71316. private _dragEnterHandler;
  71317. private _dragOverHandler;
  71318. private _dropHandler;
  71319. /**
  71320. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71321. * @param elementToMonitor defines the DOM element to track
  71322. */
  71323. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71324. /**
  71325. * Release all associated resources
  71326. */
  71327. dispose(): void;
  71328. private renderFunction;
  71329. private drag;
  71330. private drop;
  71331. private _traverseFolder;
  71332. private _processFiles;
  71333. /**
  71334. * Load files from a drop event
  71335. * @param event defines the drop event to use as source
  71336. */
  71337. loadFiles(event: any): void;
  71338. private _processReload;
  71339. /**
  71340. * Reload the current scene from the loaded files
  71341. */
  71342. reload(): void;
  71343. }
  71344. }
  71345. declare module BABYLON {
  71346. /**
  71347. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71348. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71349. */
  71350. export class SceneOptimization {
  71351. /**
  71352. * Defines the priority of this optimization (0 by default which means first in the list)
  71353. */
  71354. priority: number;
  71355. /**
  71356. * Gets a string describing the action executed by the current optimization
  71357. * @returns description string
  71358. */
  71359. getDescription(): string;
  71360. /**
  71361. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71362. * @param scene defines the current scene where to apply this optimization
  71363. * @param optimizer defines the current optimizer
  71364. * @returns true if everything that can be done was applied
  71365. */
  71366. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71367. /**
  71368. * Creates the SceneOptimization object
  71369. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71370. * @param desc defines the description associated with the optimization
  71371. */
  71372. constructor(
  71373. /**
  71374. * Defines the priority of this optimization (0 by default which means first in the list)
  71375. */
  71376. priority?: number);
  71377. }
  71378. /**
  71379. * Defines an optimization used to reduce the size of render target textures
  71380. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71381. */
  71382. export class TextureOptimization extends SceneOptimization {
  71383. /**
  71384. * Defines the priority of this optimization (0 by default which means first in the list)
  71385. */
  71386. priority: number;
  71387. /**
  71388. * 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
  71389. */
  71390. maximumSize: number;
  71391. /**
  71392. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71393. */
  71394. step: number;
  71395. /**
  71396. * Gets a string describing the action executed by the current optimization
  71397. * @returns description string
  71398. */
  71399. getDescription(): string;
  71400. /**
  71401. * Creates the TextureOptimization object
  71402. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71403. * @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
  71404. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71405. */
  71406. constructor(
  71407. /**
  71408. * Defines the priority of this optimization (0 by default which means first in the list)
  71409. */
  71410. priority?: number,
  71411. /**
  71412. * 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
  71413. */
  71414. maximumSize?: number,
  71415. /**
  71416. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71417. */
  71418. step?: number);
  71419. /**
  71420. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71421. * @param scene defines the current scene where to apply this optimization
  71422. * @param optimizer defines the current optimizer
  71423. * @returns true if everything that can be done was applied
  71424. */
  71425. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71426. }
  71427. /**
  71428. * Defines an optimization used to increase or decrease the rendering resolution
  71429. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71430. */
  71431. export class HardwareScalingOptimization extends SceneOptimization {
  71432. /**
  71433. * Defines the priority of this optimization (0 by default which means first in the list)
  71434. */
  71435. priority: number;
  71436. /**
  71437. * Defines the maximum scale to use (2 by default)
  71438. */
  71439. maximumScale: number;
  71440. /**
  71441. * Defines the step to use between two passes (0.5 by default)
  71442. */
  71443. step: number;
  71444. private _currentScale;
  71445. private _directionOffset;
  71446. /**
  71447. * Gets a string describing the action executed by the current optimization
  71448. * @return description string
  71449. */
  71450. getDescription(): string;
  71451. /**
  71452. * Creates the HardwareScalingOptimization object
  71453. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71454. * @param maximumScale defines the maximum scale to use (2 by default)
  71455. * @param step defines the step to use between two passes (0.5 by default)
  71456. */
  71457. constructor(
  71458. /**
  71459. * Defines the priority of this optimization (0 by default which means first in the list)
  71460. */
  71461. priority?: number,
  71462. /**
  71463. * Defines the maximum scale to use (2 by default)
  71464. */
  71465. maximumScale?: number,
  71466. /**
  71467. * Defines the step to use between two passes (0.5 by default)
  71468. */
  71469. step?: number);
  71470. /**
  71471. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71472. * @param scene defines the current scene where to apply this optimization
  71473. * @param optimizer defines the current optimizer
  71474. * @returns true if everything that can be done was applied
  71475. */
  71476. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71477. }
  71478. /**
  71479. * Defines an optimization used to remove shadows
  71480. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71481. */
  71482. export class ShadowsOptimization extends SceneOptimization {
  71483. /**
  71484. * Gets a string describing the action executed by the current optimization
  71485. * @return description string
  71486. */
  71487. getDescription(): string;
  71488. /**
  71489. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71490. * @param scene defines the current scene where to apply this optimization
  71491. * @param optimizer defines the current optimizer
  71492. * @returns true if everything that can be done was applied
  71493. */
  71494. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71495. }
  71496. /**
  71497. * Defines an optimization used to turn post-processes off
  71498. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71499. */
  71500. export class PostProcessesOptimization extends SceneOptimization {
  71501. /**
  71502. * Gets a string describing the action executed by the current optimization
  71503. * @return description string
  71504. */
  71505. getDescription(): string;
  71506. /**
  71507. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71508. * @param scene defines the current scene where to apply this optimization
  71509. * @param optimizer defines the current optimizer
  71510. * @returns true if everything that can be done was applied
  71511. */
  71512. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71513. }
  71514. /**
  71515. * Defines an optimization used to turn lens flares off
  71516. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71517. */
  71518. export class LensFlaresOptimization extends SceneOptimization {
  71519. /**
  71520. * Gets a string describing the action executed by the current optimization
  71521. * @return description string
  71522. */
  71523. getDescription(): string;
  71524. /**
  71525. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71526. * @param scene defines the current scene where to apply this optimization
  71527. * @param optimizer defines the current optimizer
  71528. * @returns true if everything that can be done was applied
  71529. */
  71530. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71531. }
  71532. /**
  71533. * Defines an optimization based on user defined callback.
  71534. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71535. */
  71536. export class CustomOptimization extends SceneOptimization {
  71537. /**
  71538. * Callback called to apply the custom optimization.
  71539. */
  71540. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71541. /**
  71542. * Callback called to get custom description
  71543. */
  71544. onGetDescription: () => string;
  71545. /**
  71546. * Gets a string describing the action executed by the current optimization
  71547. * @returns description string
  71548. */
  71549. getDescription(): string;
  71550. /**
  71551. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71552. * @param scene defines the current scene where to apply this optimization
  71553. * @param optimizer defines the current optimizer
  71554. * @returns true if everything that can be done was applied
  71555. */
  71556. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71557. }
  71558. /**
  71559. * Defines an optimization used to turn particles off
  71560. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71561. */
  71562. export class ParticlesOptimization extends SceneOptimization {
  71563. /**
  71564. * Gets a string describing the action executed by the current optimization
  71565. * @return description string
  71566. */
  71567. getDescription(): string;
  71568. /**
  71569. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71570. * @param scene defines the current scene where to apply this optimization
  71571. * @param optimizer defines the current optimizer
  71572. * @returns true if everything that can be done was applied
  71573. */
  71574. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71575. }
  71576. /**
  71577. * Defines an optimization used to turn render targets off
  71578. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71579. */
  71580. export class RenderTargetsOptimization extends SceneOptimization {
  71581. /**
  71582. * Gets a string describing the action executed by the current optimization
  71583. * @return description string
  71584. */
  71585. getDescription(): string;
  71586. /**
  71587. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71588. * @param scene defines the current scene where to apply this optimization
  71589. * @param optimizer defines the current optimizer
  71590. * @returns true if everything that can be done was applied
  71591. */
  71592. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71593. }
  71594. /**
  71595. * Defines an optimization used to merge meshes with compatible materials
  71596. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71597. */
  71598. export class MergeMeshesOptimization extends SceneOptimization {
  71599. private static _UpdateSelectionTree;
  71600. /**
  71601. * Gets or sets a boolean which defines if optimization octree has to be updated
  71602. */
  71603. static get UpdateSelectionTree(): boolean;
  71604. /**
  71605. * Gets or sets a boolean which defines if optimization octree has to be updated
  71606. */
  71607. static set UpdateSelectionTree(value: boolean);
  71608. /**
  71609. * Gets a string describing the action executed by the current optimization
  71610. * @return description string
  71611. */
  71612. getDescription(): string;
  71613. private _canBeMerged;
  71614. /**
  71615. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71616. * @param scene defines the current scene where to apply this optimization
  71617. * @param optimizer defines the current optimizer
  71618. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71619. * @returns true if everything that can be done was applied
  71620. */
  71621. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71622. }
  71623. /**
  71624. * Defines a list of options used by SceneOptimizer
  71625. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71626. */
  71627. export class SceneOptimizerOptions {
  71628. /**
  71629. * Defines the target frame rate to reach (60 by default)
  71630. */
  71631. targetFrameRate: number;
  71632. /**
  71633. * Defines the interval between two checkes (2000ms by default)
  71634. */
  71635. trackerDuration: number;
  71636. /**
  71637. * Gets the list of optimizations to apply
  71638. */
  71639. optimizations: SceneOptimization[];
  71640. /**
  71641. * Creates a new list of options used by SceneOptimizer
  71642. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71643. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71644. */
  71645. constructor(
  71646. /**
  71647. * Defines the target frame rate to reach (60 by default)
  71648. */
  71649. targetFrameRate?: number,
  71650. /**
  71651. * Defines the interval between two checkes (2000ms by default)
  71652. */
  71653. trackerDuration?: number);
  71654. /**
  71655. * Add a new optimization
  71656. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71657. * @returns the current SceneOptimizerOptions
  71658. */
  71659. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71660. /**
  71661. * Add a new custom optimization
  71662. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71663. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71664. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71665. * @returns the current SceneOptimizerOptions
  71666. */
  71667. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71668. /**
  71669. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71670. * @param targetFrameRate defines the target frame rate (60 by default)
  71671. * @returns a SceneOptimizerOptions object
  71672. */
  71673. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71674. /**
  71675. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71676. * @param targetFrameRate defines the target frame rate (60 by default)
  71677. * @returns a SceneOptimizerOptions object
  71678. */
  71679. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71680. /**
  71681. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71682. * @param targetFrameRate defines the target frame rate (60 by default)
  71683. * @returns a SceneOptimizerOptions object
  71684. */
  71685. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71686. }
  71687. /**
  71688. * Class used to run optimizations in order to reach a target frame rate
  71689. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71690. */
  71691. export class SceneOptimizer implements IDisposable {
  71692. private _isRunning;
  71693. private _options;
  71694. private _scene;
  71695. private _currentPriorityLevel;
  71696. private _targetFrameRate;
  71697. private _trackerDuration;
  71698. private _currentFrameRate;
  71699. private _sceneDisposeObserver;
  71700. private _improvementMode;
  71701. /**
  71702. * Defines an observable called when the optimizer reaches the target frame rate
  71703. */
  71704. onSuccessObservable: Observable<SceneOptimizer>;
  71705. /**
  71706. * Defines an observable called when the optimizer enables an optimization
  71707. */
  71708. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71709. /**
  71710. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71711. */
  71712. onFailureObservable: Observable<SceneOptimizer>;
  71713. /**
  71714. * Gets a boolean indicating if the optimizer is in improvement mode
  71715. */
  71716. get isInImprovementMode(): boolean;
  71717. /**
  71718. * Gets the current priority level (0 at start)
  71719. */
  71720. get currentPriorityLevel(): number;
  71721. /**
  71722. * Gets the current frame rate checked by the SceneOptimizer
  71723. */
  71724. get currentFrameRate(): number;
  71725. /**
  71726. * Gets or sets the current target frame rate (60 by default)
  71727. */
  71728. get targetFrameRate(): number;
  71729. /**
  71730. * Gets or sets the current target frame rate (60 by default)
  71731. */
  71732. set targetFrameRate(value: number);
  71733. /**
  71734. * Gets or sets the current interval between two checks (every 2000ms by default)
  71735. */
  71736. get trackerDuration(): number;
  71737. /**
  71738. * Gets or sets the current interval between two checks (every 2000ms by default)
  71739. */
  71740. set trackerDuration(value: number);
  71741. /**
  71742. * Gets the list of active optimizations
  71743. */
  71744. get optimizations(): SceneOptimization[];
  71745. /**
  71746. * Creates a new SceneOptimizer
  71747. * @param scene defines the scene to work on
  71748. * @param options defines the options to use with the SceneOptimizer
  71749. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71750. * @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)
  71751. */
  71752. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71753. /**
  71754. * Stops the current optimizer
  71755. */
  71756. stop(): void;
  71757. /**
  71758. * Reset the optimizer to initial step (current priority level = 0)
  71759. */
  71760. reset(): void;
  71761. /**
  71762. * Start the optimizer. By default it will try to reach a specific framerate
  71763. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71764. */
  71765. start(): void;
  71766. private _checkCurrentState;
  71767. /**
  71768. * Release all resources
  71769. */
  71770. dispose(): void;
  71771. /**
  71772. * Helper function to create a SceneOptimizer with one single line of code
  71773. * @param scene defines the scene to work on
  71774. * @param options defines the options to use with the SceneOptimizer
  71775. * @param onSuccess defines a callback to call on success
  71776. * @param onFailure defines a callback to call on failure
  71777. * @returns the new SceneOptimizer object
  71778. */
  71779. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71780. }
  71781. }
  71782. declare module BABYLON {
  71783. /**
  71784. * Class used to serialize a scene into a string
  71785. */
  71786. export class SceneSerializer {
  71787. /**
  71788. * Clear cache used by a previous serialization
  71789. */
  71790. static ClearCache(): void;
  71791. /**
  71792. * Serialize a scene into a JSON compatible object
  71793. * @param scene defines the scene to serialize
  71794. * @returns a JSON compatible object
  71795. */
  71796. static Serialize(scene: Scene): any;
  71797. /**
  71798. * Serialize a mesh into a JSON compatible object
  71799. * @param toSerialize defines the mesh to serialize
  71800. * @param withParents defines if parents must be serialized as well
  71801. * @param withChildren defines if children must be serialized as well
  71802. * @returns a JSON compatible object
  71803. */
  71804. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  71805. }
  71806. }
  71807. declare module BABYLON {
  71808. /**
  71809. * Class used to host texture specific utilities
  71810. */
  71811. export class TextureTools {
  71812. /**
  71813. * Uses the GPU to create a copy texture rescaled at a given size
  71814. * @param texture Texture to copy from
  71815. * @param width defines the desired width
  71816. * @param height defines the desired height
  71817. * @param useBilinearMode defines if bilinear mode has to be used
  71818. * @return the generated texture
  71819. */
  71820. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  71821. }
  71822. }
  71823. declare module BABYLON {
  71824. /**
  71825. * This represents the different options available for the video capture.
  71826. */
  71827. export interface VideoRecorderOptions {
  71828. /** Defines the mime type of the video. */
  71829. mimeType: string;
  71830. /** Defines the FPS the video should be recorded at. */
  71831. fps: number;
  71832. /** Defines the chunk size for the recording data. */
  71833. recordChunckSize: number;
  71834. /** The audio tracks to attach to the recording. */
  71835. audioTracks?: MediaStreamTrack[];
  71836. }
  71837. /**
  71838. * This can help with recording videos from BabylonJS.
  71839. * This is based on the available WebRTC functionalities of the browser.
  71840. *
  71841. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71842. */
  71843. export class VideoRecorder {
  71844. private static readonly _defaultOptions;
  71845. /**
  71846. * Returns whether or not the VideoRecorder is available in your browser.
  71847. * @param engine Defines the Babylon Engine.
  71848. * @returns true if supported otherwise false.
  71849. */
  71850. static IsSupported(engine: Engine): boolean;
  71851. private readonly _options;
  71852. private _canvas;
  71853. private _mediaRecorder;
  71854. private _recordedChunks;
  71855. private _fileName;
  71856. private _resolve;
  71857. private _reject;
  71858. /**
  71859. * True when a recording is already in progress.
  71860. */
  71861. get isRecording(): boolean;
  71862. /**
  71863. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71864. * @param engine Defines the BabylonJS Engine you wish to record.
  71865. * @param options Defines options that can be used to customize the capture.
  71866. */
  71867. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71868. /**
  71869. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71870. */
  71871. stopRecording(): void;
  71872. /**
  71873. * Starts recording the canvas for a max duration specified in parameters.
  71874. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71875. * If null no automatic download will start and you can rely on the promise to get the data back.
  71876. * @param maxDuration Defines the maximum recording time in seconds.
  71877. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71878. * @return A promise callback at the end of the recording with the video data in Blob.
  71879. */
  71880. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71881. /**
  71882. * Releases internal resources used during the recording.
  71883. */
  71884. dispose(): void;
  71885. private _handleDataAvailable;
  71886. private _handleError;
  71887. private _handleStop;
  71888. }
  71889. }
  71890. declare module BABYLON {
  71891. /**
  71892. * Class containing a set of static utilities functions for screenshots
  71893. */
  71894. export class ScreenshotTools {
  71895. /**
  71896. * Captures a screenshot of the current rendering
  71897. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71898. * @param engine defines the rendering engine
  71899. * @param camera defines the source camera
  71900. * @param size This parameter can be set to a single number or to an object with the
  71901. * following (optional) properties: precision, width, height. If a single number is passed,
  71902. * it will be used for both width and height. If an object is passed, the screenshot size
  71903. * will be derived from the parameters. The precision property is a multiplier allowing
  71904. * rendering at a higher or lower resolution
  71905. * @param successCallback defines the callback receives a single parameter which contains the
  71906. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71907. * src parameter of an <img> to display it
  71908. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71909. * Check your browser for supported MIME types
  71910. */
  71911. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71912. /**
  71913. * Captures a screenshot of the current rendering
  71914. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71915. * @param engine defines the rendering engine
  71916. * @param camera defines the source camera
  71917. * @param size This parameter can be set to a single number or to an object with the
  71918. * following (optional) properties: precision, width, height. If a single number is passed,
  71919. * it will be used for both width and height. If an object is passed, the screenshot size
  71920. * will be derived from the parameters. The precision property is a multiplier allowing
  71921. * rendering at a higher or lower resolution
  71922. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71923. * Check your browser for supported MIME types
  71924. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71925. * to the src parameter of an <img> to display it
  71926. */
  71927. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71928. /**
  71929. * Generates an image screenshot from the specified camera.
  71930. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71931. * @param engine The engine to use for rendering
  71932. * @param camera The camera to use for rendering
  71933. * @param size This parameter can be set to a single number or to an object with the
  71934. * following (optional) properties: precision, width, height. If a single number is passed,
  71935. * it will be used for both width and height. If an object is passed, the screenshot size
  71936. * will be derived from the parameters. The precision property is a multiplier allowing
  71937. * rendering at a higher or lower resolution
  71938. * @param successCallback The callback receives a single parameter which contains the
  71939. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71940. * src parameter of an <img> to display it
  71941. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71942. * Check your browser for supported MIME types
  71943. * @param samples Texture samples (default: 1)
  71944. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71945. * @param fileName A name for for the downloaded file.
  71946. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71947. */
  71948. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  71949. /**
  71950. * Generates an image screenshot from the specified camera.
  71951. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71952. * @param engine The engine to use for rendering
  71953. * @param camera The camera to use for rendering
  71954. * @param size This parameter can be set to a single number or to an object with the
  71955. * following (optional) properties: precision, width, height. If a single number is passed,
  71956. * it will be used for both width and height. If an object is passed, the screenshot size
  71957. * will be derived from the parameters. The precision property is a multiplier allowing
  71958. * rendering at a higher or lower resolution
  71959. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71960. * Check your browser for supported MIME types
  71961. * @param samples Texture samples (default: 1)
  71962. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71963. * @param fileName A name for for the downloaded file.
  71964. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  71965. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71966. * to the src parameter of an <img> to display it
  71967. */
  71968. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  71969. /**
  71970. * Gets height and width for screenshot size
  71971. * @private
  71972. */
  71973. private static _getScreenshotSize;
  71974. }
  71975. }
  71976. declare module BABYLON {
  71977. /**
  71978. * Interface for a data buffer
  71979. */
  71980. export interface IDataBuffer {
  71981. /**
  71982. * Reads bytes from the data buffer.
  71983. * @param byteOffset The byte offset to read
  71984. * @param byteLength The byte length to read
  71985. * @returns A promise that resolves when the bytes are read
  71986. */
  71987. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71988. /**
  71989. * The byte length of the buffer.
  71990. */
  71991. readonly byteLength: number;
  71992. }
  71993. /**
  71994. * Utility class for reading from a data buffer
  71995. */
  71996. export class DataReader {
  71997. /**
  71998. * The data buffer associated with this data reader.
  71999. */
  72000. readonly buffer: IDataBuffer;
  72001. /**
  72002. * The current byte offset from the beginning of the data buffer.
  72003. */
  72004. byteOffset: number;
  72005. private _dataView;
  72006. private _dataByteOffset;
  72007. /**
  72008. * Constructor
  72009. * @param buffer The buffer to read
  72010. */
  72011. constructor(buffer: IDataBuffer);
  72012. /**
  72013. * Loads the given byte length.
  72014. * @param byteLength The byte length to load
  72015. * @returns A promise that resolves when the load is complete
  72016. */
  72017. loadAsync(byteLength: number): Promise<void>;
  72018. /**
  72019. * Read a unsigned 32-bit integer from the currently loaded data range.
  72020. * @returns The 32-bit integer read
  72021. */
  72022. readUint32(): number;
  72023. /**
  72024. * Read a byte array from the currently loaded data range.
  72025. * @param byteLength The byte length to read
  72026. * @returns The byte array read
  72027. */
  72028. readUint8Array(byteLength: number): Uint8Array;
  72029. /**
  72030. * Read a string from the currently loaded data range.
  72031. * @param byteLength The byte length to read
  72032. * @returns The string read
  72033. */
  72034. readString(byteLength: number): string;
  72035. /**
  72036. * Skips the given byte length the currently loaded data range.
  72037. * @param byteLength The byte length to skip
  72038. */
  72039. skipBytes(byteLength: number): void;
  72040. }
  72041. }
  72042. declare module BABYLON {
  72043. /**
  72044. * Class for storing data to local storage if available or in-memory storage otherwise
  72045. */
  72046. export class DataStorage {
  72047. private static _Storage;
  72048. private static _GetStorage;
  72049. /**
  72050. * Reads a string from the data storage
  72051. * @param key The key to read
  72052. * @param defaultValue The value if the key doesn't exist
  72053. * @returns The string value
  72054. */
  72055. static ReadString(key: string, defaultValue: string): string;
  72056. /**
  72057. * Writes a string to the data storage
  72058. * @param key The key to write
  72059. * @param value The value to write
  72060. */
  72061. static WriteString(key: string, value: string): void;
  72062. /**
  72063. * Reads a boolean from the data storage
  72064. * @param key The key to read
  72065. * @param defaultValue The value if the key doesn't exist
  72066. * @returns The boolean value
  72067. */
  72068. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72069. /**
  72070. * Writes a boolean to the data storage
  72071. * @param key The key to write
  72072. * @param value The value to write
  72073. */
  72074. static WriteBoolean(key: string, value: boolean): void;
  72075. /**
  72076. * Reads a number from the data storage
  72077. * @param key The key to read
  72078. * @param defaultValue The value if the key doesn't exist
  72079. * @returns The number value
  72080. */
  72081. static ReadNumber(key: string, defaultValue: number): number;
  72082. /**
  72083. * Writes a number to the data storage
  72084. * @param key The key to write
  72085. * @param value The value to write
  72086. */
  72087. static WriteNumber(key: string, value: number): void;
  72088. }
  72089. }
  72090. declare module BABYLON {
  72091. /**
  72092. * An interface for all Hit test features
  72093. */
  72094. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72095. /**
  72096. * Triggered when new babylon (transformed) hit test results are available
  72097. */
  72098. onHitTestResultObservable: Observable<T[]>;
  72099. }
  72100. /**
  72101. * Options used for hit testing
  72102. */
  72103. export interface IWebXRLegacyHitTestOptions {
  72104. /**
  72105. * Only test when user interacted with the scene. Default - hit test every frame
  72106. */
  72107. testOnPointerDownOnly?: boolean;
  72108. /**
  72109. * The node to use to transform the local results to world coordinates
  72110. */
  72111. worldParentNode?: TransformNode;
  72112. }
  72113. /**
  72114. * Interface defining the babylon result of raycasting/hit-test
  72115. */
  72116. export interface IWebXRLegacyHitResult {
  72117. /**
  72118. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72119. */
  72120. transformationMatrix: Matrix;
  72121. /**
  72122. * The native hit test result
  72123. */
  72124. xrHitResult: XRHitResult | XRHitTestResult;
  72125. }
  72126. /**
  72127. * The currently-working hit-test module.
  72128. * Hit test (or Ray-casting) is used to interact with the real world.
  72129. * For further information read here - https://github.com/immersive-web/hit-test
  72130. */
  72131. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72132. /**
  72133. * options to use when constructing this feature
  72134. */
  72135. readonly options: IWebXRLegacyHitTestOptions;
  72136. private _direction;
  72137. private _mat;
  72138. private _onSelectEnabled;
  72139. private _origin;
  72140. /**
  72141. * The module's name
  72142. */
  72143. static readonly Name: string;
  72144. /**
  72145. * The (Babylon) version of this module.
  72146. * This is an integer representing the implementation version.
  72147. * This number does not correspond to the WebXR specs version
  72148. */
  72149. static readonly Version: number;
  72150. /**
  72151. * Populated with the last native XR Hit Results
  72152. */
  72153. lastNativeXRHitResults: XRHitResult[];
  72154. /**
  72155. * Triggered when new babylon (transformed) hit test results are available
  72156. */
  72157. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72158. /**
  72159. * Creates a new instance of the (legacy version) hit test feature
  72160. * @param _xrSessionManager an instance of WebXRSessionManager
  72161. * @param options options to use when constructing this feature
  72162. */
  72163. constructor(_xrSessionManager: WebXRSessionManager,
  72164. /**
  72165. * options to use when constructing this feature
  72166. */
  72167. options?: IWebXRLegacyHitTestOptions);
  72168. /**
  72169. * execute a hit test with an XR Ray
  72170. *
  72171. * @param xrSession a native xrSession that will execute this hit test
  72172. * @param xrRay the ray (position and direction) to use for ray-casting
  72173. * @param referenceSpace native XR reference space to use for the hit-test
  72174. * @param filter filter function that will filter the results
  72175. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72176. */
  72177. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72178. /**
  72179. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72180. * @param event the (select) event to use to select with
  72181. * @param referenceSpace the reference space to use for this hit test
  72182. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72183. */
  72184. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72185. /**
  72186. * attach this feature
  72187. * Will usually be called by the features manager
  72188. *
  72189. * @returns true if successful.
  72190. */
  72191. attach(): boolean;
  72192. /**
  72193. * detach this feature.
  72194. * Will usually be called by the features manager
  72195. *
  72196. * @returns true if successful.
  72197. */
  72198. detach(): boolean;
  72199. /**
  72200. * Dispose this feature and all of the resources attached
  72201. */
  72202. dispose(): void;
  72203. protected _onXRFrame(frame: XRFrame): void;
  72204. private _onHitTestResults;
  72205. private _onSelect;
  72206. }
  72207. }
  72208. declare module BABYLON {
  72209. /**
  72210. * Options used for hit testing (version 2)
  72211. */
  72212. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72213. /**
  72214. * Do not create a permanent hit test. Will usually be used when only
  72215. * transient inputs are needed.
  72216. */
  72217. disablePermanentHitTest?: boolean;
  72218. /**
  72219. * Enable transient (for example touch-based) hit test inspections
  72220. */
  72221. enableTransientHitTest?: boolean;
  72222. /**
  72223. * Offset ray for the permanent hit test
  72224. */
  72225. offsetRay?: Vector3;
  72226. /**
  72227. * Offset ray for the transient hit test
  72228. */
  72229. transientOffsetRay?: Vector3;
  72230. /**
  72231. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72232. */
  72233. useReferenceSpace?: boolean;
  72234. }
  72235. /**
  72236. * Interface defining the babylon result of hit-test
  72237. */
  72238. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72239. /**
  72240. * The input source that generated this hit test (if transient)
  72241. */
  72242. inputSource?: XRInputSource;
  72243. /**
  72244. * Is this a transient hit test
  72245. */
  72246. isTransient?: boolean;
  72247. /**
  72248. * Position of the hit test result
  72249. */
  72250. position: Vector3;
  72251. /**
  72252. * Rotation of the hit test result
  72253. */
  72254. rotationQuaternion: Quaternion;
  72255. /**
  72256. * The native hit test result
  72257. */
  72258. xrHitResult: XRHitTestResult;
  72259. }
  72260. /**
  72261. * The currently-working hit-test module.
  72262. * Hit test (or Ray-casting) is used to interact with the real world.
  72263. * For further information read here - https://github.com/immersive-web/hit-test
  72264. *
  72265. * Tested on chrome (mobile) 80.
  72266. */
  72267. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72268. /**
  72269. * options to use when constructing this feature
  72270. */
  72271. readonly options: IWebXRHitTestOptions;
  72272. private _tmpMat;
  72273. private _tmpPos;
  72274. private _tmpQuat;
  72275. private _transientXrHitTestSource;
  72276. private _xrHitTestSource;
  72277. private initHitTestSource;
  72278. /**
  72279. * The module's name
  72280. */
  72281. static readonly Name: string;
  72282. /**
  72283. * The (Babylon) version of this module.
  72284. * This is an integer representing the implementation version.
  72285. * This number does not correspond to the WebXR specs version
  72286. */
  72287. static readonly Version: number;
  72288. /**
  72289. * When set to true, each hit test will have its own position/rotation objects
  72290. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72291. * the developers will clone them or copy them as they see fit.
  72292. */
  72293. autoCloneTransformation: boolean;
  72294. /**
  72295. * Triggered when new babylon (transformed) hit test results are available
  72296. */
  72297. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72298. /**
  72299. * Use this to temporarily pause hit test checks.
  72300. */
  72301. paused: boolean;
  72302. /**
  72303. * Creates a new instance of the hit test feature
  72304. * @param _xrSessionManager an instance of WebXRSessionManager
  72305. * @param options options to use when constructing this feature
  72306. */
  72307. constructor(_xrSessionManager: WebXRSessionManager,
  72308. /**
  72309. * options to use when constructing this feature
  72310. */
  72311. options?: IWebXRHitTestOptions);
  72312. /**
  72313. * attach this feature
  72314. * Will usually be called by the features manager
  72315. *
  72316. * @returns true if successful.
  72317. */
  72318. attach(): boolean;
  72319. /**
  72320. * detach this feature.
  72321. * Will usually be called by the features manager
  72322. *
  72323. * @returns true if successful.
  72324. */
  72325. detach(): boolean;
  72326. /**
  72327. * Dispose this feature and all of the resources attached
  72328. */
  72329. dispose(): void;
  72330. protected _onXRFrame(frame: XRFrame): void;
  72331. private _processWebXRHitTestResult;
  72332. }
  72333. }
  72334. declare module BABYLON {
  72335. /**
  72336. * Configuration options of the anchor system
  72337. */
  72338. export interface IWebXRAnchorSystemOptions {
  72339. /**
  72340. * a node that will be used to convert local to world coordinates
  72341. */
  72342. worldParentNode?: TransformNode;
  72343. /**
  72344. * If set to true a reference of the created anchors will be kept until the next session starts
  72345. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72346. */
  72347. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72348. }
  72349. /**
  72350. * A babylon container for an XR Anchor
  72351. */
  72352. export interface IWebXRAnchor {
  72353. /**
  72354. * A babylon-assigned ID for this anchor
  72355. */
  72356. id: number;
  72357. /**
  72358. * Transformation matrix to apply to an object attached to this anchor
  72359. */
  72360. transformationMatrix: Matrix;
  72361. /**
  72362. * The native anchor object
  72363. */
  72364. xrAnchor: XRAnchor;
  72365. /**
  72366. * if defined, this object will be constantly updated by the anchor's position and rotation
  72367. */
  72368. attachedNode?: TransformNode;
  72369. }
  72370. /**
  72371. * An implementation of the anchor system for WebXR.
  72372. * For further information see https://github.com/immersive-web/anchors/
  72373. */
  72374. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72375. private _options;
  72376. private _lastFrameDetected;
  72377. private _trackedAnchors;
  72378. private _referenceSpaceForFrameAnchors;
  72379. private _futureAnchors;
  72380. /**
  72381. * The module's name
  72382. */
  72383. static readonly Name: string;
  72384. /**
  72385. * The (Babylon) version of this module.
  72386. * This is an integer representing the implementation version.
  72387. * This number does not correspond to the WebXR specs version
  72388. */
  72389. static readonly Version: number;
  72390. /**
  72391. * Observers registered here will be executed when a new anchor was added to the session
  72392. */
  72393. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72394. /**
  72395. * Observers registered here will be executed when an anchor was removed from the session
  72396. */
  72397. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72398. /**
  72399. * Observers registered here will be executed when an existing anchor updates
  72400. * This can execute N times every frame
  72401. */
  72402. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72403. /**
  72404. * Set the reference space to use for anchor creation, when not using a hit test.
  72405. * Will default to the session's reference space if not defined
  72406. */
  72407. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  72408. /**
  72409. * constructs a new anchor system
  72410. * @param _xrSessionManager an instance of WebXRSessionManager
  72411. * @param _options configuration object for this feature
  72412. */
  72413. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72414. private _tmpVector;
  72415. private _tmpQuaternion;
  72416. private _populateTmpTransformation;
  72417. /**
  72418. * Create a new anchor point using a hit test result at a specific point in the scene
  72419. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72420. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72421. *
  72422. * @param hitTestResult The hit test result to use for this anchor creation
  72423. * @param position an optional position offset for this anchor
  72424. * @param rotationQuaternion an optional rotation offset for this anchor
  72425. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72426. */
  72427. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  72428. /**
  72429. * Add a new anchor at a specific position and rotation
  72430. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  72431. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  72432. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72433. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72434. *
  72435. * @param position the position in which to add an anchor
  72436. * @param rotationQuaternion an optional rotation for the anchor transformation
  72437. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  72438. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72439. */
  72440. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  72441. /**
  72442. * detach this feature.
  72443. * Will usually be called by the features manager
  72444. *
  72445. * @returns true if successful.
  72446. */
  72447. detach(): boolean;
  72448. /**
  72449. * Dispose this feature and all of the resources attached
  72450. */
  72451. dispose(): void;
  72452. protected _onXRFrame(frame: XRFrame): void;
  72453. /**
  72454. * avoiding using Array.find for global support.
  72455. * @param xrAnchor the plane to find in the array
  72456. */
  72457. private _findIndexInAnchorArray;
  72458. private _updateAnchorWithXRFrame;
  72459. private _createAnchorAtTransformation;
  72460. }
  72461. }
  72462. declare module BABYLON {
  72463. /**
  72464. * Options used in the plane detector module
  72465. */
  72466. export interface IWebXRPlaneDetectorOptions {
  72467. /**
  72468. * The node to use to transform the local results to world coordinates
  72469. */
  72470. worldParentNode?: TransformNode;
  72471. /**
  72472. * If set to true a reference of the created planes will be kept until the next session starts
  72473. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  72474. */
  72475. doNotRemovePlanesOnSessionEnded?: boolean;
  72476. }
  72477. /**
  72478. * A babylon interface for a WebXR plane.
  72479. * A Plane is actually a polygon, built from N points in space
  72480. *
  72481. * Supported in chrome 79, not supported in canary 81 ATM
  72482. */
  72483. export interface IWebXRPlane {
  72484. /**
  72485. * a babylon-assigned ID for this polygon
  72486. */
  72487. id: number;
  72488. /**
  72489. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72490. */
  72491. polygonDefinition: Array<Vector3>;
  72492. /**
  72493. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72494. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72495. */
  72496. transformationMatrix: Matrix;
  72497. /**
  72498. * the native xr-plane object
  72499. */
  72500. xrPlane: XRPlane;
  72501. }
  72502. /**
  72503. * The plane detector is used to detect planes in the real world when in AR
  72504. * For more information see https://github.com/immersive-web/real-world-geometry/
  72505. */
  72506. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72507. private _options;
  72508. private _detectedPlanes;
  72509. private _enabled;
  72510. private _lastFrameDetected;
  72511. /**
  72512. * The module's name
  72513. */
  72514. static readonly Name: string;
  72515. /**
  72516. * The (Babylon) version of this module.
  72517. * This is an integer representing the implementation version.
  72518. * This number does not correspond to the WebXR specs version
  72519. */
  72520. static readonly Version: number;
  72521. /**
  72522. * Observers registered here will be executed when a new plane was added to the session
  72523. */
  72524. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72525. /**
  72526. * Observers registered here will be executed when a plane is no longer detected in the session
  72527. */
  72528. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72529. /**
  72530. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72531. * This can execute N times every frame
  72532. */
  72533. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72534. /**
  72535. * construct a new Plane Detector
  72536. * @param _xrSessionManager an instance of xr Session manager
  72537. * @param _options configuration to use when constructing this feature
  72538. */
  72539. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72540. /**
  72541. * detach this feature.
  72542. * Will usually be called by the features manager
  72543. *
  72544. * @returns true if successful.
  72545. */
  72546. detach(): boolean;
  72547. /**
  72548. * Dispose this feature and all of the resources attached
  72549. */
  72550. dispose(): void;
  72551. protected _onXRFrame(frame: XRFrame): void;
  72552. private _init;
  72553. private _updatePlaneWithXRPlane;
  72554. /**
  72555. * avoiding using Array.find for global support.
  72556. * @param xrPlane the plane to find in the array
  72557. */
  72558. private findIndexInPlaneArray;
  72559. }
  72560. }
  72561. declare module BABYLON {
  72562. /**
  72563. * Options interface for the background remover plugin
  72564. */
  72565. export interface IWebXRBackgroundRemoverOptions {
  72566. /**
  72567. * Further background meshes to disable when entering AR
  72568. */
  72569. backgroundMeshes?: AbstractMesh[];
  72570. /**
  72571. * flags to configure the removal of the environment helper.
  72572. * If not set, the entire background will be removed. If set, flags should be set as well.
  72573. */
  72574. environmentHelperRemovalFlags?: {
  72575. /**
  72576. * Should the skybox be removed (default false)
  72577. */
  72578. skyBox?: boolean;
  72579. /**
  72580. * Should the ground be removed (default false)
  72581. */
  72582. ground?: boolean;
  72583. };
  72584. /**
  72585. * don't disable the environment helper
  72586. */
  72587. ignoreEnvironmentHelper?: boolean;
  72588. }
  72589. /**
  72590. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72591. */
  72592. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72593. /**
  72594. * read-only options to be used in this module
  72595. */
  72596. readonly options: IWebXRBackgroundRemoverOptions;
  72597. /**
  72598. * The module's name
  72599. */
  72600. static readonly Name: string;
  72601. /**
  72602. * The (Babylon) version of this module.
  72603. * This is an integer representing the implementation version.
  72604. * This number does not correspond to the WebXR specs version
  72605. */
  72606. static readonly Version: number;
  72607. /**
  72608. * registered observers will be triggered when the background state changes
  72609. */
  72610. onBackgroundStateChangedObservable: Observable<boolean>;
  72611. /**
  72612. * constructs a new background remover module
  72613. * @param _xrSessionManager the session manager for this module
  72614. * @param options read-only options to be used in this module
  72615. */
  72616. constructor(_xrSessionManager: WebXRSessionManager,
  72617. /**
  72618. * read-only options to be used in this module
  72619. */
  72620. options?: IWebXRBackgroundRemoverOptions);
  72621. /**
  72622. * attach this feature
  72623. * Will usually be called by the features manager
  72624. *
  72625. * @returns true if successful.
  72626. */
  72627. attach(): boolean;
  72628. /**
  72629. * detach this feature.
  72630. * Will usually be called by the features manager
  72631. *
  72632. * @returns true if successful.
  72633. */
  72634. detach(): boolean;
  72635. /**
  72636. * Dispose this feature and all of the resources attached
  72637. */
  72638. dispose(): void;
  72639. protected _onXRFrame(_xrFrame: XRFrame): void;
  72640. private _setBackgroundState;
  72641. }
  72642. }
  72643. declare module BABYLON {
  72644. /**
  72645. * Options for the controller physics feature
  72646. */
  72647. export class IWebXRControllerPhysicsOptions {
  72648. /**
  72649. * Should the headset get its own impostor
  72650. */
  72651. enableHeadsetImpostor?: boolean;
  72652. /**
  72653. * Optional parameters for the headset impostor
  72654. */
  72655. headsetImpostorParams?: {
  72656. /**
  72657. * The type of impostor to create. Default is sphere
  72658. */
  72659. impostorType: number;
  72660. /**
  72661. * the size of the impostor. Defaults to 10cm
  72662. */
  72663. impostorSize?: number | {
  72664. width: number;
  72665. height: number;
  72666. depth: number;
  72667. };
  72668. /**
  72669. * Friction definitions
  72670. */
  72671. friction?: number;
  72672. /**
  72673. * Restitution
  72674. */
  72675. restitution?: number;
  72676. };
  72677. /**
  72678. * The physics properties of the future impostors
  72679. */
  72680. physicsProperties?: {
  72681. /**
  72682. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72683. * Note that this requires a physics engine that supports mesh impostors!
  72684. */
  72685. useControllerMesh?: boolean;
  72686. /**
  72687. * The type of impostor to create. Default is sphere
  72688. */
  72689. impostorType?: number;
  72690. /**
  72691. * the size of the impostor. Defaults to 10cm
  72692. */
  72693. impostorSize?: number | {
  72694. width: number;
  72695. height: number;
  72696. depth: number;
  72697. };
  72698. /**
  72699. * Friction definitions
  72700. */
  72701. friction?: number;
  72702. /**
  72703. * Restitution
  72704. */
  72705. restitution?: number;
  72706. };
  72707. /**
  72708. * the xr input to use with this pointer selection
  72709. */
  72710. xrInput: WebXRInput;
  72711. }
  72712. /**
  72713. * Add physics impostor to your webxr controllers,
  72714. * including naive calculation of their linear and angular velocity
  72715. */
  72716. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72717. private readonly _options;
  72718. private _attachController;
  72719. private _controllers;
  72720. private _debugMode;
  72721. private _delta;
  72722. private _headsetImpostor?;
  72723. private _headsetMesh?;
  72724. private _lastTimestamp;
  72725. private _tmpQuaternion;
  72726. private _tmpVector;
  72727. /**
  72728. * The module's name
  72729. */
  72730. static readonly Name: string;
  72731. /**
  72732. * The (Babylon) version of this module.
  72733. * This is an integer representing the implementation version.
  72734. * This number does not correspond to the webxr specs version
  72735. */
  72736. static readonly Version: number;
  72737. /**
  72738. * Construct a new Controller Physics Feature
  72739. * @param _xrSessionManager the corresponding xr session manager
  72740. * @param _options options to create this feature with
  72741. */
  72742. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72743. /**
  72744. * @hidden
  72745. * enable debugging - will show console outputs and the impostor mesh
  72746. */
  72747. _enablePhysicsDebug(): void;
  72748. /**
  72749. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72750. * @param xrController the controller to add
  72751. */
  72752. addController(xrController: WebXRInputSource): void;
  72753. /**
  72754. * attach this feature
  72755. * Will usually be called by the features manager
  72756. *
  72757. * @returns true if successful.
  72758. */
  72759. attach(): boolean;
  72760. /**
  72761. * detach this feature.
  72762. * Will usually be called by the features manager
  72763. *
  72764. * @returns true if successful.
  72765. */
  72766. detach(): boolean;
  72767. /**
  72768. * Get the headset impostor, if enabled
  72769. * @returns the impostor
  72770. */
  72771. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72772. /**
  72773. * Get the physics impostor of a specific controller.
  72774. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72775. * @param controller the controller or the controller id of which to get the impostor
  72776. * @returns the impostor or null
  72777. */
  72778. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72779. /**
  72780. * Update the physics properties provided in the constructor
  72781. * @param newProperties the new properties object
  72782. */
  72783. setPhysicsProperties(newProperties: {
  72784. impostorType?: number;
  72785. impostorSize?: number | {
  72786. width: number;
  72787. height: number;
  72788. depth: number;
  72789. };
  72790. friction?: number;
  72791. restitution?: number;
  72792. }): void;
  72793. protected _onXRFrame(_xrFrame: any): void;
  72794. private _detachController;
  72795. }
  72796. }
  72797. declare module BABYLON {
  72798. /**
  72799. * The motion controller class for all microsoft mixed reality controllers
  72800. */
  72801. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72802. protected readonly _mapping: {
  72803. defaultButton: {
  72804. valueNodeName: string;
  72805. unpressedNodeName: string;
  72806. pressedNodeName: string;
  72807. };
  72808. defaultAxis: {
  72809. valueNodeName: string;
  72810. minNodeName: string;
  72811. maxNodeName: string;
  72812. };
  72813. buttons: {
  72814. "xr-standard-trigger": {
  72815. rootNodeName: string;
  72816. componentProperty: string;
  72817. states: string[];
  72818. };
  72819. "xr-standard-squeeze": {
  72820. rootNodeName: string;
  72821. componentProperty: string;
  72822. states: string[];
  72823. };
  72824. "xr-standard-touchpad": {
  72825. rootNodeName: string;
  72826. labelAnchorNodeName: string;
  72827. touchPointNodeName: string;
  72828. };
  72829. "xr-standard-thumbstick": {
  72830. rootNodeName: string;
  72831. componentProperty: string;
  72832. states: string[];
  72833. };
  72834. };
  72835. axes: {
  72836. "xr-standard-touchpad": {
  72837. "x-axis": {
  72838. rootNodeName: string;
  72839. };
  72840. "y-axis": {
  72841. rootNodeName: string;
  72842. };
  72843. };
  72844. "xr-standard-thumbstick": {
  72845. "x-axis": {
  72846. rootNodeName: string;
  72847. };
  72848. "y-axis": {
  72849. rootNodeName: string;
  72850. };
  72851. };
  72852. };
  72853. };
  72854. /**
  72855. * The base url used to load the left and right controller models
  72856. */
  72857. static MODEL_BASE_URL: string;
  72858. /**
  72859. * The name of the left controller model file
  72860. */
  72861. static MODEL_LEFT_FILENAME: string;
  72862. /**
  72863. * The name of the right controller model file
  72864. */
  72865. static MODEL_RIGHT_FILENAME: string;
  72866. profileId: string;
  72867. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72868. protected _getFilenameAndPath(): {
  72869. filename: string;
  72870. path: string;
  72871. };
  72872. protected _getModelLoadingConstraints(): boolean;
  72873. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72874. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72875. protected _updateModel(): void;
  72876. }
  72877. }
  72878. declare module BABYLON {
  72879. /**
  72880. * The motion controller class for oculus touch (quest, rift).
  72881. * This class supports legacy mapping as well the standard xr mapping
  72882. */
  72883. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72884. private _forceLegacyControllers;
  72885. private _modelRootNode;
  72886. /**
  72887. * The base url used to load the left and right controller models
  72888. */
  72889. static MODEL_BASE_URL: string;
  72890. /**
  72891. * The name of the left controller model file
  72892. */
  72893. static MODEL_LEFT_FILENAME: string;
  72894. /**
  72895. * The name of the right controller model file
  72896. */
  72897. static MODEL_RIGHT_FILENAME: string;
  72898. /**
  72899. * Base Url for the Quest controller model.
  72900. */
  72901. static QUEST_MODEL_BASE_URL: string;
  72902. profileId: string;
  72903. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  72904. protected _getFilenameAndPath(): {
  72905. filename: string;
  72906. path: string;
  72907. };
  72908. protected _getModelLoadingConstraints(): boolean;
  72909. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72910. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72911. protected _updateModel(): void;
  72912. /**
  72913. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  72914. * between the touch and touch 2.
  72915. */
  72916. private _isQuest;
  72917. }
  72918. }
  72919. declare module BABYLON {
  72920. /**
  72921. * The motion controller class for the standard HTC-Vive controllers
  72922. */
  72923. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  72924. private _modelRootNode;
  72925. /**
  72926. * The base url used to load the left and right controller models
  72927. */
  72928. static MODEL_BASE_URL: string;
  72929. /**
  72930. * File name for the controller model.
  72931. */
  72932. static MODEL_FILENAME: string;
  72933. profileId: string;
  72934. /**
  72935. * Create a new Vive motion controller object
  72936. * @param scene the scene to use to create this controller
  72937. * @param gamepadObject the corresponding gamepad object
  72938. * @param handedness the handedness of the controller
  72939. */
  72940. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  72941. protected _getFilenameAndPath(): {
  72942. filename: string;
  72943. path: string;
  72944. };
  72945. protected _getModelLoadingConstraints(): boolean;
  72946. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72947. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72948. protected _updateModel(): void;
  72949. }
  72950. }
  72951. declare module BABYLON {
  72952. /**
  72953. * A cursor which tracks a point on a path
  72954. */
  72955. export class PathCursor {
  72956. private path;
  72957. /**
  72958. * Stores path cursor callbacks for when an onchange event is triggered
  72959. */
  72960. private _onchange;
  72961. /**
  72962. * The value of the path cursor
  72963. */
  72964. value: number;
  72965. /**
  72966. * The animation array of the path cursor
  72967. */
  72968. animations: Animation[];
  72969. /**
  72970. * Initializes the path cursor
  72971. * @param path The path to track
  72972. */
  72973. constructor(path: Path2);
  72974. /**
  72975. * Gets the cursor point on the path
  72976. * @returns A point on the path cursor at the cursor location
  72977. */
  72978. getPoint(): Vector3;
  72979. /**
  72980. * Moves the cursor ahead by the step amount
  72981. * @param step The amount to move the cursor forward
  72982. * @returns This path cursor
  72983. */
  72984. moveAhead(step?: number): PathCursor;
  72985. /**
  72986. * Moves the cursor behind by the step amount
  72987. * @param step The amount to move the cursor back
  72988. * @returns This path cursor
  72989. */
  72990. moveBack(step?: number): PathCursor;
  72991. /**
  72992. * Moves the cursor by the step amount
  72993. * If the step amount is greater than one, an exception is thrown
  72994. * @param step The amount to move the cursor
  72995. * @returns This path cursor
  72996. */
  72997. move(step: number): PathCursor;
  72998. /**
  72999. * Ensures that the value is limited between zero and one
  73000. * @returns This path cursor
  73001. */
  73002. private ensureLimits;
  73003. /**
  73004. * Runs onchange callbacks on change (used by the animation engine)
  73005. * @returns This path cursor
  73006. */
  73007. private raiseOnChange;
  73008. /**
  73009. * Executes a function on change
  73010. * @param f A path cursor onchange callback
  73011. * @returns This path cursor
  73012. */
  73013. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73014. }
  73015. }
  73016. declare module BABYLON {
  73017. /** @hidden */
  73018. export var blurPixelShader: {
  73019. name: string;
  73020. shader: string;
  73021. };
  73022. }
  73023. declare module BABYLON {
  73024. /** @hidden */
  73025. export var pointCloudVertexDeclaration: {
  73026. name: string;
  73027. shader: string;
  73028. };
  73029. }
  73030. // Mixins
  73031. interface Window {
  73032. mozIndexedDB: IDBFactory;
  73033. webkitIndexedDB: IDBFactory;
  73034. msIndexedDB: IDBFactory;
  73035. webkitURL: typeof URL;
  73036. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73037. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73038. WebGLRenderingContext: WebGLRenderingContext;
  73039. MSGesture: MSGesture;
  73040. CANNON: any;
  73041. AudioContext: AudioContext;
  73042. webkitAudioContext: AudioContext;
  73043. PointerEvent: any;
  73044. Math: Math;
  73045. Uint8Array: Uint8ArrayConstructor;
  73046. Float32Array: Float32ArrayConstructor;
  73047. mozURL: typeof URL;
  73048. msURL: typeof URL;
  73049. VRFrameData: any; // WebVR, from specs 1.1
  73050. DracoDecoderModule: any;
  73051. setImmediate(handler: (...args: any[]) => void): number;
  73052. }
  73053. interface HTMLCanvasElement {
  73054. requestPointerLock(): void;
  73055. msRequestPointerLock?(): void;
  73056. mozRequestPointerLock?(): void;
  73057. webkitRequestPointerLock?(): void;
  73058. /** Track wether a record is in progress */
  73059. isRecording: boolean;
  73060. /** Capture Stream method defined by some browsers */
  73061. captureStream(fps?: number): MediaStream;
  73062. }
  73063. interface CanvasRenderingContext2D {
  73064. msImageSmoothingEnabled: boolean;
  73065. }
  73066. interface MouseEvent {
  73067. mozMovementX: number;
  73068. mozMovementY: number;
  73069. webkitMovementX: number;
  73070. webkitMovementY: number;
  73071. msMovementX: number;
  73072. msMovementY: number;
  73073. }
  73074. interface Navigator {
  73075. mozGetVRDevices: (any: any) => any;
  73076. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73077. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73078. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73079. webkitGetGamepads(): Gamepad[];
  73080. msGetGamepads(): Gamepad[];
  73081. webkitGamepads(): Gamepad[];
  73082. }
  73083. interface HTMLVideoElement {
  73084. mozSrcObject: any;
  73085. }
  73086. interface Math {
  73087. fround(x: number): number;
  73088. imul(a: number, b: number): number;
  73089. }
  73090. interface WebGLRenderingContext {
  73091. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73092. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73093. vertexAttribDivisor(index: number, divisor: number): void;
  73094. createVertexArray(): any;
  73095. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73096. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73097. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73098. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73099. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73100. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73101. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73102. // Queries
  73103. createQuery(): WebGLQuery;
  73104. deleteQuery(query: WebGLQuery): void;
  73105. beginQuery(target: number, query: WebGLQuery): void;
  73106. endQuery(target: number): void;
  73107. getQueryParameter(query: WebGLQuery, pname: number): any;
  73108. getQuery(target: number, pname: number): any;
  73109. MAX_SAMPLES: number;
  73110. RGBA8: number;
  73111. READ_FRAMEBUFFER: number;
  73112. DRAW_FRAMEBUFFER: number;
  73113. UNIFORM_BUFFER: number;
  73114. HALF_FLOAT_OES: number;
  73115. RGBA16F: number;
  73116. RGBA32F: number;
  73117. R32F: number;
  73118. RG32F: number;
  73119. RGB32F: number;
  73120. R16F: number;
  73121. RG16F: number;
  73122. RGB16F: number;
  73123. RED: number;
  73124. RG: number;
  73125. R8: number;
  73126. RG8: number;
  73127. UNSIGNED_INT_24_8: number;
  73128. DEPTH24_STENCIL8: number;
  73129. MIN: number;
  73130. MAX: number;
  73131. /* Multiple Render Targets */
  73132. drawBuffers(buffers: number[]): void;
  73133. readBuffer(src: number): void;
  73134. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73135. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73136. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73137. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73138. // Occlusion Query
  73139. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73140. ANY_SAMPLES_PASSED: number;
  73141. QUERY_RESULT_AVAILABLE: number;
  73142. QUERY_RESULT: number;
  73143. }
  73144. interface WebGLProgram {
  73145. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73146. }
  73147. interface EXT_disjoint_timer_query {
  73148. QUERY_COUNTER_BITS_EXT: number;
  73149. TIME_ELAPSED_EXT: number;
  73150. TIMESTAMP_EXT: number;
  73151. GPU_DISJOINT_EXT: number;
  73152. QUERY_RESULT_EXT: number;
  73153. QUERY_RESULT_AVAILABLE_EXT: number;
  73154. queryCounterEXT(query: WebGLQuery, target: number): void;
  73155. createQueryEXT(): WebGLQuery;
  73156. beginQueryEXT(target: number, query: WebGLQuery): void;
  73157. endQueryEXT(target: number): void;
  73158. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73159. deleteQueryEXT(query: WebGLQuery): void;
  73160. }
  73161. interface WebGLUniformLocation {
  73162. _currentState: any;
  73163. }
  73164. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73165. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73166. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73167. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73168. interface WebGLRenderingContext {
  73169. readonly RASTERIZER_DISCARD: number;
  73170. readonly DEPTH_COMPONENT24: number;
  73171. readonly TEXTURE_3D: number;
  73172. readonly TEXTURE_2D_ARRAY: number;
  73173. readonly TEXTURE_COMPARE_FUNC: number;
  73174. readonly TEXTURE_COMPARE_MODE: number;
  73175. readonly COMPARE_REF_TO_TEXTURE: number;
  73176. readonly TEXTURE_WRAP_R: number;
  73177. readonly HALF_FLOAT: number;
  73178. readonly RGB8: number;
  73179. readonly RED_INTEGER: number;
  73180. readonly RG_INTEGER: number;
  73181. readonly RGB_INTEGER: number;
  73182. readonly RGBA_INTEGER: number;
  73183. readonly R8_SNORM: number;
  73184. readonly RG8_SNORM: number;
  73185. readonly RGB8_SNORM: number;
  73186. readonly RGBA8_SNORM: number;
  73187. readonly R8I: number;
  73188. readonly RG8I: number;
  73189. readonly RGB8I: number;
  73190. readonly RGBA8I: number;
  73191. readonly R8UI: number;
  73192. readonly RG8UI: number;
  73193. readonly RGB8UI: number;
  73194. readonly RGBA8UI: number;
  73195. readonly R16I: number;
  73196. readonly RG16I: number;
  73197. readonly RGB16I: number;
  73198. readonly RGBA16I: number;
  73199. readonly R16UI: number;
  73200. readonly RG16UI: number;
  73201. readonly RGB16UI: number;
  73202. readonly RGBA16UI: number;
  73203. readonly R32I: number;
  73204. readonly RG32I: number;
  73205. readonly RGB32I: number;
  73206. readonly RGBA32I: number;
  73207. readonly R32UI: number;
  73208. readonly RG32UI: number;
  73209. readonly RGB32UI: number;
  73210. readonly RGBA32UI: number;
  73211. readonly RGB10_A2UI: number;
  73212. readonly R11F_G11F_B10F: number;
  73213. readonly RGB9_E5: number;
  73214. readonly RGB10_A2: number;
  73215. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73216. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73217. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73218. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73219. readonly DEPTH_COMPONENT32F: number;
  73220. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73221. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73222. 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;
  73223. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73224. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73225. readonly TRANSFORM_FEEDBACK: number;
  73226. readonly INTERLEAVED_ATTRIBS: number;
  73227. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73228. createTransformFeedback(): WebGLTransformFeedback;
  73229. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73230. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73231. beginTransformFeedback(primitiveMode: number): void;
  73232. endTransformFeedback(): void;
  73233. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73234. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73235. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73236. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73237. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73238. }
  73239. interface ImageBitmap {
  73240. readonly width: number;
  73241. readonly height: number;
  73242. close(): void;
  73243. }
  73244. interface WebGLQuery extends WebGLObject {
  73245. }
  73246. declare var WebGLQuery: {
  73247. prototype: WebGLQuery;
  73248. new(): WebGLQuery;
  73249. };
  73250. interface WebGLSampler extends WebGLObject {
  73251. }
  73252. declare var WebGLSampler: {
  73253. prototype: WebGLSampler;
  73254. new(): WebGLSampler;
  73255. };
  73256. interface WebGLSync extends WebGLObject {
  73257. }
  73258. declare var WebGLSync: {
  73259. prototype: WebGLSync;
  73260. new(): WebGLSync;
  73261. };
  73262. interface WebGLTransformFeedback extends WebGLObject {
  73263. }
  73264. declare var WebGLTransformFeedback: {
  73265. prototype: WebGLTransformFeedback;
  73266. new(): WebGLTransformFeedback;
  73267. };
  73268. interface WebGLVertexArrayObject extends WebGLObject {
  73269. }
  73270. declare var WebGLVertexArrayObject: {
  73271. prototype: WebGLVertexArrayObject;
  73272. new(): WebGLVertexArrayObject;
  73273. };
  73274. // Type definitions for WebVR API
  73275. // Project: https://w3c.github.io/webvr/
  73276. // Definitions by: six a <https://github.com/lostfictions>
  73277. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73278. interface VRDisplay extends EventTarget {
  73279. /**
  73280. * Dictionary of capabilities describing the VRDisplay.
  73281. */
  73282. readonly capabilities: VRDisplayCapabilities;
  73283. /**
  73284. * z-depth defining the far plane of the eye view frustum
  73285. * enables mapping of values in the render target depth
  73286. * attachment to scene coordinates. Initially set to 10000.0.
  73287. */
  73288. depthFar: number;
  73289. /**
  73290. * z-depth defining the near plane of the eye view frustum
  73291. * enables mapping of values in the render target depth
  73292. * attachment to scene coordinates. Initially set to 0.01.
  73293. */
  73294. depthNear: number;
  73295. /**
  73296. * An identifier for this distinct VRDisplay. Used as an
  73297. * association point in the Gamepad API.
  73298. */
  73299. readonly displayId: number;
  73300. /**
  73301. * A display name, a user-readable name identifying it.
  73302. */
  73303. readonly displayName: string;
  73304. readonly isConnected: boolean;
  73305. readonly isPresenting: boolean;
  73306. /**
  73307. * If this VRDisplay supports room-scale experiences, the optional
  73308. * stage attribute contains details on the room-scale parameters.
  73309. */
  73310. readonly stageParameters: VRStageParameters | null;
  73311. /**
  73312. * Passing the value returned by `requestAnimationFrame` to
  73313. * `cancelAnimationFrame` will unregister the callback.
  73314. * @param handle Define the hanle of the request to cancel
  73315. */
  73316. cancelAnimationFrame(handle: number): void;
  73317. /**
  73318. * Stops presenting to the VRDisplay.
  73319. * @returns a promise to know when it stopped
  73320. */
  73321. exitPresent(): Promise<void>;
  73322. /**
  73323. * Return the current VREyeParameters for the given eye.
  73324. * @param whichEye Define the eye we want the parameter for
  73325. * @returns the eye parameters
  73326. */
  73327. getEyeParameters(whichEye: string): VREyeParameters;
  73328. /**
  73329. * Populates the passed VRFrameData with the information required to render
  73330. * the current frame.
  73331. * @param frameData Define the data structure to populate
  73332. * @returns true if ok otherwise false
  73333. */
  73334. getFrameData(frameData: VRFrameData): boolean;
  73335. /**
  73336. * Get the layers currently being presented.
  73337. * @returns the list of VR layers
  73338. */
  73339. getLayers(): VRLayer[];
  73340. /**
  73341. * Return a VRPose containing the future predicted pose of the VRDisplay
  73342. * when the current frame will be presented. The value returned will not
  73343. * change until JavaScript has returned control to the browser.
  73344. *
  73345. * The VRPose will contain the position, orientation, velocity,
  73346. * and acceleration of each of these properties.
  73347. * @returns the pose object
  73348. */
  73349. getPose(): VRPose;
  73350. /**
  73351. * Return the current instantaneous pose of the VRDisplay, with no
  73352. * prediction applied.
  73353. * @returns the current instantaneous pose
  73354. */
  73355. getImmediatePose(): VRPose;
  73356. /**
  73357. * The callback passed to `requestAnimationFrame` will be called
  73358. * any time a new frame should be rendered. When the VRDisplay is
  73359. * presenting the callback will be called at the native refresh
  73360. * rate of the HMD. When not presenting this function acts
  73361. * identically to how window.requestAnimationFrame acts. Content should
  73362. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73363. * asynchronously from other displays and at differing refresh rates.
  73364. * @param callback Define the eaction to run next frame
  73365. * @returns the request handle it
  73366. */
  73367. requestAnimationFrame(callback: FrameRequestCallback): number;
  73368. /**
  73369. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73370. * Repeat calls while already presenting will update the VRLayers being displayed.
  73371. * @param layers Define the list of layer to present
  73372. * @returns a promise to know when the request has been fulfilled
  73373. */
  73374. requestPresent(layers: VRLayer[]): Promise<void>;
  73375. /**
  73376. * Reset the pose for this display, treating its current position and
  73377. * orientation as the "origin/zero" values. VRPose.position,
  73378. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73379. * updated when calling resetPose(). This should be called in only
  73380. * sitting-space experiences.
  73381. */
  73382. resetPose(): void;
  73383. /**
  73384. * The VRLayer provided to the VRDisplay will be captured and presented
  73385. * in the HMD. Calling this function has the same effect on the source
  73386. * canvas as any other operation that uses its source image, and canvases
  73387. * created without preserveDrawingBuffer set to true will be cleared.
  73388. * @param pose Define the pose to submit
  73389. */
  73390. submitFrame(pose?: VRPose): void;
  73391. }
  73392. declare var VRDisplay: {
  73393. prototype: VRDisplay;
  73394. new(): VRDisplay;
  73395. };
  73396. interface VRLayer {
  73397. leftBounds?: number[] | Float32Array | null;
  73398. rightBounds?: number[] | Float32Array | null;
  73399. source?: HTMLCanvasElement | null;
  73400. }
  73401. interface VRDisplayCapabilities {
  73402. readonly canPresent: boolean;
  73403. readonly hasExternalDisplay: boolean;
  73404. readonly hasOrientation: boolean;
  73405. readonly hasPosition: boolean;
  73406. readonly maxLayers: number;
  73407. }
  73408. interface VREyeParameters {
  73409. /** @deprecated */
  73410. readonly fieldOfView: VRFieldOfView;
  73411. readonly offset: Float32Array;
  73412. readonly renderHeight: number;
  73413. readonly renderWidth: number;
  73414. }
  73415. interface VRFieldOfView {
  73416. readonly downDegrees: number;
  73417. readonly leftDegrees: number;
  73418. readonly rightDegrees: number;
  73419. readonly upDegrees: number;
  73420. }
  73421. interface VRFrameData {
  73422. readonly leftProjectionMatrix: Float32Array;
  73423. readonly leftViewMatrix: Float32Array;
  73424. readonly pose: VRPose;
  73425. readonly rightProjectionMatrix: Float32Array;
  73426. readonly rightViewMatrix: Float32Array;
  73427. readonly timestamp: number;
  73428. }
  73429. interface VRPose {
  73430. readonly angularAcceleration: Float32Array | null;
  73431. readonly angularVelocity: Float32Array | null;
  73432. readonly linearAcceleration: Float32Array | null;
  73433. readonly linearVelocity: Float32Array | null;
  73434. readonly orientation: Float32Array | null;
  73435. readonly position: Float32Array | null;
  73436. readonly timestamp: number;
  73437. }
  73438. interface VRStageParameters {
  73439. sittingToStandingTransform?: Float32Array;
  73440. sizeX?: number;
  73441. sizeY?: number;
  73442. }
  73443. interface Navigator {
  73444. getVRDisplays(): Promise<VRDisplay[]>;
  73445. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73446. }
  73447. interface Window {
  73448. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73449. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73450. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73451. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73452. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73453. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73454. }
  73455. interface Gamepad {
  73456. readonly displayId: number;
  73457. }
  73458. type XRSessionMode =
  73459. | "inline"
  73460. | "immersive-vr"
  73461. | "immersive-ar";
  73462. type XRReferenceSpaceType =
  73463. | "viewer"
  73464. | "local"
  73465. | "local-floor"
  73466. | "bounded-floor"
  73467. | "unbounded";
  73468. type XREnvironmentBlendMode =
  73469. | "opaque"
  73470. | "additive"
  73471. | "alpha-blend";
  73472. type XRVisibilityState =
  73473. | "visible"
  73474. | "visible-blurred"
  73475. | "hidden";
  73476. type XRHandedness =
  73477. | "none"
  73478. | "left"
  73479. | "right";
  73480. type XRTargetRayMode =
  73481. | "gaze"
  73482. | "tracked-pointer"
  73483. | "screen";
  73484. type XREye =
  73485. | "none"
  73486. | "left"
  73487. | "right";
  73488. type XREventType =
  73489. | "devicechange"
  73490. | "visibilitychange"
  73491. | "end"
  73492. | "inputsourceschange"
  73493. | "select"
  73494. | "selectstart"
  73495. | "selectend"
  73496. | "squeeze"
  73497. | "squeezestart"
  73498. | "squeezeend"
  73499. | "reset";
  73500. interface XRSpace extends EventTarget {
  73501. }
  73502. interface XRRenderState {
  73503. depthNear?: number;
  73504. depthFar?: number;
  73505. inlineVerticalFieldOfView?: number;
  73506. baseLayer?: XRWebGLLayer;
  73507. }
  73508. interface XRInputSource {
  73509. handedness: XRHandedness;
  73510. targetRayMode: XRTargetRayMode;
  73511. targetRaySpace: XRSpace;
  73512. gripSpace: XRSpace | undefined;
  73513. gamepad: Gamepad | undefined;
  73514. profiles: Array<string>;
  73515. }
  73516. interface XRSessionInit {
  73517. optionalFeatures?: string[];
  73518. requiredFeatures?: string[];
  73519. }
  73520. interface XRSession {
  73521. addEventListener: Function;
  73522. removeEventListener: Function;
  73523. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  73524. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  73525. requestAnimationFrame: Function;
  73526. end(): Promise<void>;
  73527. renderState: XRRenderState;
  73528. inputSources: Array<XRInputSource>;
  73529. // hit test
  73530. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  73531. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  73532. // legacy AR hit test
  73533. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73534. // legacy plane detection
  73535. updateWorldTrackingState(options: {
  73536. planeDetectionState?: { enabled: boolean; }
  73537. }): void;
  73538. }
  73539. interface XRReferenceSpace extends XRSpace {
  73540. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  73541. onreset: any;
  73542. }
  73543. type XRPlaneSet = Set<XRPlane>;
  73544. type XRAnchorSet = Set<XRAnchor>;
  73545. interface XRFrame {
  73546. session: XRSession;
  73547. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  73548. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  73549. // AR
  73550. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  73551. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  73552. // Anchors
  73553. trackedAnchors?: XRAnchorSet;
  73554. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  73555. // Planes
  73556. worldInformation: {
  73557. detectedPlanes?: XRPlaneSet;
  73558. };
  73559. }
  73560. interface XRViewerPose extends XRPose {
  73561. views: Array<XRView>;
  73562. }
  73563. interface XRPose {
  73564. transform: XRRigidTransform;
  73565. emulatedPosition: boolean;
  73566. }
  73567. interface XRWebGLLayerOptions {
  73568. antialias?: boolean;
  73569. depth?: boolean;
  73570. stencil?: boolean;
  73571. alpha?: boolean;
  73572. multiview?: boolean;
  73573. framebufferScaleFactor?: number;
  73574. }
  73575. declare var XRWebGLLayer: {
  73576. prototype: XRWebGLLayer;
  73577. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  73578. };
  73579. interface XRWebGLLayer {
  73580. framebuffer: WebGLFramebuffer;
  73581. framebufferWidth: number;
  73582. framebufferHeight: number;
  73583. getViewport: Function;
  73584. }
  73585. declare class XRRigidTransform {
  73586. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  73587. position: DOMPointReadOnly;
  73588. orientation: DOMPointReadOnly;
  73589. matrix: Float32Array;
  73590. inverse: XRRigidTransform;
  73591. }
  73592. interface XRView {
  73593. eye: XREye;
  73594. projectionMatrix: Float32Array;
  73595. transform: XRRigidTransform;
  73596. }
  73597. interface XRInputSourceChangeEvent {
  73598. session: XRSession;
  73599. removed: Array<XRInputSource>;
  73600. added: Array<XRInputSource>;
  73601. }
  73602. interface XRInputSourceEvent extends Event {
  73603. readonly frame: XRFrame;
  73604. readonly inputSource: XRInputSource;
  73605. }
  73606. // Experimental(er) features
  73607. declare class XRRay {
  73608. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  73609. origin: DOMPointReadOnly;
  73610. direction: DOMPointReadOnly;
  73611. matrix: Float32Array;
  73612. }
  73613. declare enum XRHitTestTrackableType {
  73614. "point",
  73615. "plane"
  73616. }
  73617. interface XRHitResult {
  73618. hitMatrix: Float32Array;
  73619. }
  73620. interface XRTransientInputHitTestResult {
  73621. readonly inputSource: XRInputSource;
  73622. readonly results: Array<XRHitTestResult>;
  73623. }
  73624. interface XRHitTestResult {
  73625. getPose(baseSpace: XRSpace): XRPose | undefined;
  73626. // When anchor system is enabled
  73627. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  73628. }
  73629. interface XRHitTestSource {
  73630. cancel(): void;
  73631. }
  73632. interface XRTransientInputHitTestSource {
  73633. cancel(): void;
  73634. }
  73635. interface XRHitTestOptionsInit {
  73636. space: XRSpace;
  73637. entityTypes?: Array<XRHitTestTrackableType>;
  73638. offsetRay?: XRRay;
  73639. }
  73640. interface XRTransientInputHitTestOptionsInit {
  73641. profile: string;
  73642. entityTypes?: Array<XRHitTestTrackableType>;
  73643. offsetRay?: XRRay;
  73644. }
  73645. interface XRAnchor {
  73646. anchorSpace: XRSpace;
  73647. delete(): void;
  73648. }
  73649. interface XRPlane {
  73650. orientation: "Horizontal" | "Vertical";
  73651. planeSpace: XRSpace;
  73652. polygon: Array<DOMPointReadOnly>;
  73653. lastChangedTime: number;
  73654. }
  73655. /**
  73656. * @ignore
  73657. */
  73658. declare module BABYLON.GLTF2.Exporter {
  73659. }
  73660. /**
  73661. * @ignore
  73662. */
  73663. declare module BABYLON.GLTF1 {
  73664. }
  73665. declare module BABYLON.GUI {
  73666. /**
  73667. * Class used to specific a value and its associated unit
  73668. */
  73669. export class ValueAndUnit {
  73670. /** defines the unit to store */
  73671. unit: number;
  73672. /** defines a boolean indicating if the value can be negative */
  73673. negativeValueAllowed: boolean;
  73674. private _value;
  73675. private _originalUnit;
  73676. /**
  73677. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  73678. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73679. */
  73680. ignoreAdaptiveScaling: boolean;
  73681. /**
  73682. * Creates a new ValueAndUnit
  73683. * @param value defines the value to store
  73684. * @param unit defines the unit to store
  73685. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  73686. */
  73687. constructor(value: number,
  73688. /** defines the unit to store */
  73689. unit?: number,
  73690. /** defines a boolean indicating if the value can be negative */
  73691. negativeValueAllowed?: boolean);
  73692. /** Gets a boolean indicating if the value is a percentage */
  73693. get isPercentage(): boolean;
  73694. /** Gets a boolean indicating if the value is store as pixel */
  73695. get isPixel(): boolean;
  73696. /** Gets direct internal value */
  73697. get internalValue(): number;
  73698. /**
  73699. * Gets value as pixel
  73700. * @param host defines the root host
  73701. * @param refValue defines the reference value for percentages
  73702. * @returns the value as pixel
  73703. */
  73704. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  73705. /**
  73706. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  73707. * @param value defines the value to store
  73708. * @param unit defines the unit to store
  73709. * @returns the current ValueAndUnit
  73710. */
  73711. updateInPlace(value: number, unit?: number): ValueAndUnit;
  73712. /**
  73713. * Gets the value accordingly to its unit
  73714. * @param host defines the root host
  73715. * @returns the value
  73716. */
  73717. getValue(host: AdvancedDynamicTexture): number;
  73718. /**
  73719. * Gets a string representation of the value
  73720. * @param host defines the root host
  73721. * @param decimals defines an optional number of decimals to display
  73722. * @returns a string
  73723. */
  73724. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  73725. /**
  73726. * Store a value parsed from a string
  73727. * @param source defines the source string
  73728. * @returns true if the value was successfully parsed
  73729. */
  73730. fromString(source: string | number): boolean;
  73731. private static _Regex;
  73732. private static _UNITMODE_PERCENTAGE;
  73733. private static _UNITMODE_PIXEL;
  73734. /** UNITMODE_PERCENTAGE */
  73735. static get UNITMODE_PERCENTAGE(): number;
  73736. /** UNITMODE_PIXEL */
  73737. static get UNITMODE_PIXEL(): number;
  73738. }
  73739. }
  73740. declare module BABYLON.GUI {
  73741. /**
  73742. * Define a style used by control to automatically setup properties based on a template.
  73743. * Only support font related properties so far
  73744. */
  73745. export class Style implements BABYLON.IDisposable {
  73746. private _fontFamily;
  73747. private _fontStyle;
  73748. private _fontWeight;
  73749. /** @hidden */
  73750. _host: AdvancedDynamicTexture;
  73751. /** @hidden */
  73752. _fontSize: ValueAndUnit;
  73753. /**
  73754. * BABYLON.Observable raised when the style values are changed
  73755. */
  73756. onChangedObservable: BABYLON.Observable<Style>;
  73757. /**
  73758. * Creates a new style object
  73759. * @param host defines the AdvancedDynamicTexture which hosts this style
  73760. */
  73761. constructor(host: AdvancedDynamicTexture);
  73762. /**
  73763. * Gets or sets the font size
  73764. */
  73765. get fontSize(): string | number;
  73766. set fontSize(value: string | number);
  73767. /**
  73768. * Gets or sets the font family
  73769. */
  73770. get fontFamily(): string;
  73771. set fontFamily(value: string);
  73772. /**
  73773. * Gets or sets the font style
  73774. */
  73775. get fontStyle(): string;
  73776. set fontStyle(value: string);
  73777. /** Gets or sets font weight */
  73778. get fontWeight(): string;
  73779. set fontWeight(value: string);
  73780. /** Dispose all associated resources */
  73781. dispose(): void;
  73782. }
  73783. }
  73784. declare module BABYLON.GUI {
  73785. /**
  73786. * Class used to transport BABYLON.Vector2 information for pointer events
  73787. */
  73788. export class Vector2WithInfo extends BABYLON.Vector2 {
  73789. /** defines the current mouse button index */
  73790. buttonIndex: number;
  73791. /**
  73792. * Creates a new Vector2WithInfo
  73793. * @param source defines the vector2 data to transport
  73794. * @param buttonIndex defines the current mouse button index
  73795. */
  73796. constructor(source: BABYLON.Vector2,
  73797. /** defines the current mouse button index */
  73798. buttonIndex?: number);
  73799. }
  73800. /** Class used to provide 2D matrix features */
  73801. export class Matrix2D {
  73802. /** Gets the internal array of 6 floats used to store matrix data */
  73803. m: Float32Array;
  73804. /**
  73805. * Creates a new matrix
  73806. * @param m00 defines value for (0, 0)
  73807. * @param m01 defines value for (0, 1)
  73808. * @param m10 defines value for (1, 0)
  73809. * @param m11 defines value for (1, 1)
  73810. * @param m20 defines value for (2, 0)
  73811. * @param m21 defines value for (2, 1)
  73812. */
  73813. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  73814. /**
  73815. * Fills the matrix from direct values
  73816. * @param m00 defines value for (0, 0)
  73817. * @param m01 defines value for (0, 1)
  73818. * @param m10 defines value for (1, 0)
  73819. * @param m11 defines value for (1, 1)
  73820. * @param m20 defines value for (2, 0)
  73821. * @param m21 defines value for (2, 1)
  73822. * @returns the current modified matrix
  73823. */
  73824. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  73825. /**
  73826. * Gets matrix determinant
  73827. * @returns the determinant
  73828. */
  73829. determinant(): number;
  73830. /**
  73831. * Inverses the matrix and stores it in a target matrix
  73832. * @param result defines the target matrix
  73833. * @returns the current matrix
  73834. */
  73835. invertToRef(result: Matrix2D): Matrix2D;
  73836. /**
  73837. * Multiplies the current matrix with another one
  73838. * @param other defines the second operand
  73839. * @param result defines the target matrix
  73840. * @returns the current matrix
  73841. */
  73842. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  73843. /**
  73844. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  73845. * @param x defines the x coordinate to transform
  73846. * @param y defines the x coordinate to transform
  73847. * @param result defines the target vector2
  73848. * @returns the current matrix
  73849. */
  73850. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  73851. /**
  73852. * Creates an identity matrix
  73853. * @returns a new matrix
  73854. */
  73855. static Identity(): Matrix2D;
  73856. /**
  73857. * Creates a translation matrix and stores it in a target matrix
  73858. * @param x defines the x coordinate of the translation
  73859. * @param y defines the y coordinate of the translation
  73860. * @param result defines the target matrix
  73861. */
  73862. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  73863. /**
  73864. * Creates a scaling matrix and stores it in a target matrix
  73865. * @param x defines the x coordinate of the scaling
  73866. * @param y defines the y coordinate of the scaling
  73867. * @param result defines the target matrix
  73868. */
  73869. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  73870. /**
  73871. * Creates a rotation matrix and stores it in a target matrix
  73872. * @param angle defines the rotation angle
  73873. * @param result defines the target matrix
  73874. */
  73875. static RotationToRef(angle: number, result: Matrix2D): void;
  73876. private static _TempPreTranslationMatrix;
  73877. private static _TempPostTranslationMatrix;
  73878. private static _TempRotationMatrix;
  73879. private static _TempScalingMatrix;
  73880. private static _TempCompose0;
  73881. private static _TempCompose1;
  73882. private static _TempCompose2;
  73883. /**
  73884. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  73885. * @param tx defines the x coordinate of the translation
  73886. * @param ty defines the y coordinate of the translation
  73887. * @param angle defines the rotation angle
  73888. * @param scaleX defines the x coordinate of the scaling
  73889. * @param scaleY defines the y coordinate of the scaling
  73890. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  73891. * @param result defines the target matrix
  73892. */
  73893. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  73894. }
  73895. }
  73896. declare module BABYLON.GUI {
  73897. /**
  73898. * Class used to store 2D control sizes
  73899. */
  73900. export class Measure {
  73901. /** defines left coordinate */
  73902. left: number;
  73903. /** defines top coordinate */
  73904. top: number;
  73905. /** defines width dimension */
  73906. width: number;
  73907. /** defines height dimension */
  73908. height: number;
  73909. /**
  73910. * Creates a new measure
  73911. * @param left defines left coordinate
  73912. * @param top defines top coordinate
  73913. * @param width defines width dimension
  73914. * @param height defines height dimension
  73915. */
  73916. constructor(
  73917. /** defines left coordinate */
  73918. left: number,
  73919. /** defines top coordinate */
  73920. top: number,
  73921. /** defines width dimension */
  73922. width: number,
  73923. /** defines height dimension */
  73924. height: number);
  73925. /**
  73926. * Copy from another measure
  73927. * @param other defines the other measure to copy from
  73928. */
  73929. copyFrom(other: Measure): void;
  73930. /**
  73931. * Copy from a group of 4 floats
  73932. * @param left defines left coordinate
  73933. * @param top defines top coordinate
  73934. * @param width defines width dimension
  73935. * @param height defines height dimension
  73936. */
  73937. copyFromFloats(left: number, top: number, width: number, height: number): void;
  73938. /**
  73939. * Computes the axis aligned bounding box measure for two given measures
  73940. * @param a Input measure
  73941. * @param b Input measure
  73942. * @param result the resulting bounding measure
  73943. */
  73944. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  73945. /**
  73946. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  73947. * @param transform the matrix to transform the measure before computing the AABB
  73948. * @param result the resulting AABB
  73949. */
  73950. transformToRef(transform: Matrix2D, result: Measure): void;
  73951. /**
  73952. * Check equality between this measure and another one
  73953. * @param other defines the other measures
  73954. * @returns true if both measures are equals
  73955. */
  73956. isEqualsTo(other: Measure): boolean;
  73957. /**
  73958. * Creates an empty measure
  73959. * @returns a new measure
  73960. */
  73961. static Empty(): Measure;
  73962. }
  73963. }
  73964. declare module BABYLON.GUI {
  73965. /**
  73966. * Interface used to define a control that can receive focus
  73967. */
  73968. export interface IFocusableControl {
  73969. /**
  73970. * Function called when the control receives the focus
  73971. */
  73972. onFocus(): void;
  73973. /**
  73974. * Function called when the control loses the focus
  73975. */
  73976. onBlur(): void;
  73977. /**
  73978. * Function called to let the control handle keyboard events
  73979. * @param evt defines the current keyboard event
  73980. */
  73981. processKeyboard(evt: KeyboardEvent): void;
  73982. /**
  73983. * Function called to get the list of controls that should not steal the focus from this control
  73984. * @returns an array of controls
  73985. */
  73986. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73987. }
  73988. /**
  73989. * Class used to create texture to support 2D GUI elements
  73990. * @see http://doc.babylonjs.com/how_to/gui
  73991. */
  73992. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  73993. private _isDirty;
  73994. private _renderObserver;
  73995. private _resizeObserver;
  73996. private _preKeyboardObserver;
  73997. private _pointerMoveObserver;
  73998. private _pointerObserver;
  73999. private _canvasPointerOutObserver;
  74000. private _background;
  74001. /** @hidden */
  74002. _rootContainer: Container;
  74003. /** @hidden */
  74004. _lastPickedControl: Control;
  74005. /** @hidden */
  74006. _lastControlOver: {
  74007. [pointerId: number]: Control;
  74008. };
  74009. /** @hidden */
  74010. _lastControlDown: {
  74011. [pointerId: number]: Control;
  74012. };
  74013. /** @hidden */
  74014. _capturingControl: {
  74015. [pointerId: number]: Control;
  74016. };
  74017. /** @hidden */
  74018. _shouldBlockPointer: boolean;
  74019. /** @hidden */
  74020. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  74021. /** @hidden */
  74022. _linkedControls: Control[];
  74023. private _isFullscreen;
  74024. private _fullscreenViewport;
  74025. private _idealWidth;
  74026. private _idealHeight;
  74027. private _useSmallestIdeal;
  74028. private _renderAtIdealSize;
  74029. private _focusedControl;
  74030. private _blockNextFocusCheck;
  74031. private _renderScale;
  74032. private _rootElement;
  74033. private _cursorChanged;
  74034. private _defaultMousePointerId;
  74035. /** @hidden */
  74036. _numLayoutCalls: number;
  74037. /** Gets the number of layout calls made the last time the ADT has been rendered */
  74038. get numLayoutCalls(): number;
  74039. /** @hidden */
  74040. _numRenderCalls: number;
  74041. /** Gets the number of render calls made the last time the ADT has been rendered */
  74042. get numRenderCalls(): number;
  74043. /**
  74044. * Define type to string to ensure compatibility across browsers
  74045. * Safari doesn't support DataTransfer constructor
  74046. */
  74047. private _clipboardData;
  74048. /**
  74049. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  74050. */
  74051. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  74052. /**
  74053. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  74054. */
  74055. onControlPickedObservable: BABYLON.Observable<Control>;
  74056. /**
  74057. * BABYLON.Observable event triggered before layout is evaluated
  74058. */
  74059. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74060. /**
  74061. * BABYLON.Observable event triggered after the layout was evaluated
  74062. */
  74063. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74064. /**
  74065. * BABYLON.Observable event triggered before the texture is rendered
  74066. */
  74067. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74068. /**
  74069. * BABYLON.Observable event triggered after the texture was rendered
  74070. */
  74071. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74072. /**
  74073. * Gets or sets a boolean defining if alpha is stored as premultiplied
  74074. */
  74075. premulAlpha: boolean;
  74076. /**
  74077. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  74078. * Useful when you want more antialiasing
  74079. */
  74080. get renderScale(): number;
  74081. set renderScale(value: number);
  74082. /** Gets or sets the background color */
  74083. get background(): string;
  74084. set background(value: string);
  74085. /**
  74086. * Gets or sets the ideal width used to design controls.
  74087. * The GUI will then rescale everything accordingly
  74088. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74089. */
  74090. get idealWidth(): number;
  74091. set idealWidth(value: number);
  74092. /**
  74093. * Gets or sets the ideal height used to design controls.
  74094. * The GUI will then rescale everything accordingly
  74095. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74096. */
  74097. get idealHeight(): number;
  74098. set idealHeight(value: number);
  74099. /**
  74100. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  74101. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74102. */
  74103. get useSmallestIdeal(): boolean;
  74104. set useSmallestIdeal(value: boolean);
  74105. /**
  74106. * Gets or sets a boolean indicating if adaptive scaling must be used
  74107. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74108. */
  74109. get renderAtIdealSize(): boolean;
  74110. set renderAtIdealSize(value: boolean);
  74111. /**
  74112. * Gets the ratio used when in "ideal mode"
  74113. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74114. * */
  74115. get idealRatio(): number;
  74116. /**
  74117. * Gets the underlying layer used to render the texture when in fullscreen mode
  74118. */
  74119. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  74120. /**
  74121. * Gets the root container control
  74122. */
  74123. get rootContainer(): Container;
  74124. /**
  74125. * Returns an array containing the root container.
  74126. * This is mostly used to let the Inspector introspects the ADT
  74127. * @returns an array containing the rootContainer
  74128. */
  74129. getChildren(): Array<Container>;
  74130. /**
  74131. * Will return all controls that are inside this texture
  74132. * @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
  74133. * @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
  74134. * @return all child controls
  74135. */
  74136. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74137. /**
  74138. * Gets or sets the current focused control
  74139. */
  74140. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74141. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74142. /**
  74143. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74144. */
  74145. get isForeground(): boolean;
  74146. set isForeground(value: boolean);
  74147. /**
  74148. * Gets or set information about clipboardData
  74149. */
  74150. get clipboardData(): string;
  74151. set clipboardData(value: string);
  74152. /**
  74153. * Creates a new AdvancedDynamicTexture
  74154. * @param name defines the name of the texture
  74155. * @param width defines the width of the texture
  74156. * @param height defines the height of the texture
  74157. * @param scene defines the hosting scene
  74158. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74159. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74160. */
  74161. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74162. /**
  74163. * Get the current class name of the texture useful for serialization or dynamic coding.
  74164. * @returns "AdvancedDynamicTexture"
  74165. */
  74166. getClassName(): string;
  74167. /**
  74168. * Function used to execute a function on all controls
  74169. * @param func defines the function to execute
  74170. * @param container defines the container where controls belong. If null the root container will be used
  74171. */
  74172. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74173. private _useInvalidateRectOptimization;
  74174. /**
  74175. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74176. */
  74177. get useInvalidateRectOptimization(): boolean;
  74178. set useInvalidateRectOptimization(value: boolean);
  74179. private _invalidatedRectangle;
  74180. /**
  74181. * Invalidates a rectangle area on the gui texture
  74182. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74183. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74184. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74185. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74186. */
  74187. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74188. /**
  74189. * Marks the texture as dirty forcing a complete update
  74190. */
  74191. markAsDirty(): void;
  74192. /**
  74193. * Helper function used to create a new style
  74194. * @returns a new style
  74195. * @see http://doc.babylonjs.com/how_to/gui#styles
  74196. */
  74197. createStyle(): Style;
  74198. /**
  74199. * Adds a new control to the root container
  74200. * @param control defines the control to add
  74201. * @returns the current texture
  74202. */
  74203. addControl(control: Control): AdvancedDynamicTexture;
  74204. /**
  74205. * Removes a control from the root container
  74206. * @param control defines the control to remove
  74207. * @returns the current texture
  74208. */
  74209. removeControl(control: Control): AdvancedDynamicTexture;
  74210. /**
  74211. * Release all resources
  74212. */
  74213. dispose(): void;
  74214. private _onResize;
  74215. /** @hidden */
  74216. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74217. /**
  74218. * Get screen coordinates for a vector3
  74219. * @param position defines the position to project
  74220. * @param worldMatrix defines the world matrix to use
  74221. * @returns the projected position
  74222. */
  74223. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74224. private _checkUpdate;
  74225. private _clearMeasure;
  74226. private _render;
  74227. /** @hidden */
  74228. _changeCursor(cursor: string): void;
  74229. /** @hidden */
  74230. _registerLastControlDown(control: Control, pointerId: number): void;
  74231. private _doPicking;
  74232. /** @hidden */
  74233. _cleanControlAfterRemovalFromList(list: {
  74234. [pointerId: number]: Control;
  74235. }, control: Control): void;
  74236. /** @hidden */
  74237. _cleanControlAfterRemoval(control: Control): void;
  74238. /** Attach to all scene events required to support pointer events */
  74239. attach(): void;
  74240. /** @hidden */
  74241. private onClipboardCopy;
  74242. /** @hidden */
  74243. private onClipboardCut;
  74244. /** @hidden */
  74245. private onClipboardPaste;
  74246. /**
  74247. * Register the clipboard Events onto the canvas
  74248. */
  74249. registerClipboardEvents(): void;
  74250. /**
  74251. * Unregister the clipboard Events from the canvas
  74252. */
  74253. unRegisterClipboardEvents(): void;
  74254. /**
  74255. * Connect the texture to a hosting mesh to enable interactions
  74256. * @param mesh defines the mesh to attach to
  74257. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74258. */
  74259. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74260. /**
  74261. * Move the focus to a specific control
  74262. * @param control defines the control which will receive the focus
  74263. */
  74264. moveFocusToControl(control: IFocusableControl): void;
  74265. private _manageFocus;
  74266. private _attachToOnPointerOut;
  74267. /**
  74268. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74269. * @param mesh defines the mesh which will receive the texture
  74270. * @param width defines the texture width (1024 by default)
  74271. * @param height defines the texture height (1024 by default)
  74272. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74273. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74274. * @returns a new AdvancedDynamicTexture
  74275. */
  74276. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74277. /**
  74278. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74279. * In this mode the texture will rely on a layer for its rendering.
  74280. * This allows it to be treated like any other layer.
  74281. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74282. * LayerMask is set through advancedTexture.layer.layerMask
  74283. * @param name defines name for the texture
  74284. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74285. * @param scene defines the hsoting scene
  74286. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74287. * @returns a new AdvancedDynamicTexture
  74288. */
  74289. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74290. }
  74291. }
  74292. declare module BABYLON.GUI {
  74293. /**
  74294. * Root class used for all 2D controls
  74295. * @see http://doc.babylonjs.com/how_to/gui#controls
  74296. */
  74297. export class Control {
  74298. /** defines the name of the control */
  74299. name?: string | undefined;
  74300. /**
  74301. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74302. */
  74303. static AllowAlphaInheritance: boolean;
  74304. private _alpha;
  74305. private _alphaSet;
  74306. private _zIndex;
  74307. /** @hidden */
  74308. _host: AdvancedDynamicTexture;
  74309. /** Gets or sets the control parent */
  74310. parent: BABYLON.Nullable<Container>;
  74311. /** @hidden */
  74312. _currentMeasure: Measure;
  74313. private _fontFamily;
  74314. private _fontStyle;
  74315. private _fontWeight;
  74316. private _fontSize;
  74317. private _font;
  74318. /** @hidden */
  74319. _width: ValueAndUnit;
  74320. /** @hidden */
  74321. _height: ValueAndUnit;
  74322. /** @hidden */
  74323. protected _fontOffset: {
  74324. ascent: number;
  74325. height: number;
  74326. descent: number;
  74327. };
  74328. private _color;
  74329. private _style;
  74330. private _styleObserver;
  74331. /** @hidden */
  74332. protected _horizontalAlignment: number;
  74333. /** @hidden */
  74334. protected _verticalAlignment: number;
  74335. /** @hidden */
  74336. protected _isDirty: boolean;
  74337. /** @hidden */
  74338. protected _wasDirty: boolean;
  74339. /** @hidden */
  74340. _tempParentMeasure: Measure;
  74341. /** @hidden */
  74342. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74343. /** @hidden */
  74344. protected _cachedParentMeasure: Measure;
  74345. private _paddingLeft;
  74346. private _paddingRight;
  74347. private _paddingTop;
  74348. private _paddingBottom;
  74349. /** @hidden */
  74350. _left: ValueAndUnit;
  74351. /** @hidden */
  74352. _top: ValueAndUnit;
  74353. private _scaleX;
  74354. private _scaleY;
  74355. private _rotation;
  74356. private _transformCenterX;
  74357. private _transformCenterY;
  74358. /** @hidden */
  74359. _transformMatrix: Matrix2D;
  74360. /** @hidden */
  74361. protected _invertTransformMatrix: Matrix2D;
  74362. /** @hidden */
  74363. protected _transformedPosition: BABYLON.Vector2;
  74364. private _isMatrixDirty;
  74365. private _cachedOffsetX;
  74366. private _cachedOffsetY;
  74367. private _isVisible;
  74368. private _isHighlighted;
  74369. /** @hidden */
  74370. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74371. private _fontSet;
  74372. private _dummyVector2;
  74373. private _downCount;
  74374. private _enterCount;
  74375. private _doNotRender;
  74376. private _downPointerIds;
  74377. protected _isEnabled: boolean;
  74378. protected _disabledColor: string;
  74379. protected _disabledColorItem: string;
  74380. /** @hidden */
  74381. protected _rebuildLayout: boolean;
  74382. /** @hidden */
  74383. _customData: any;
  74384. /** @hidden */
  74385. _isClipped: boolean;
  74386. /** @hidden */
  74387. _automaticSize: boolean;
  74388. /** @hidden */
  74389. _tag: any;
  74390. /**
  74391. * 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
  74392. */
  74393. uniqueId: number;
  74394. /**
  74395. * Gets or sets an object used to store user defined information for the node
  74396. */
  74397. metadata: any;
  74398. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74399. isHitTestVisible: boolean;
  74400. /** Gets or sets a boolean indicating if the control can block pointer events */
  74401. isPointerBlocker: boolean;
  74402. /** Gets or sets a boolean indicating if the control can be focusable */
  74403. isFocusInvisible: boolean;
  74404. /**
  74405. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74406. * 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
  74407. */
  74408. clipChildren: boolean;
  74409. /**
  74410. * Gets or sets a boolean indicating that control content must be clipped
  74411. * 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
  74412. */
  74413. clipContent: boolean;
  74414. /**
  74415. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74416. */
  74417. useBitmapCache: boolean;
  74418. private _cacheData;
  74419. private _shadowOffsetX;
  74420. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74421. get shadowOffsetX(): number;
  74422. set shadowOffsetX(value: number);
  74423. private _shadowOffsetY;
  74424. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74425. get shadowOffsetY(): number;
  74426. set shadowOffsetY(value: number);
  74427. private _shadowBlur;
  74428. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74429. get shadowBlur(): number;
  74430. set shadowBlur(value: number);
  74431. private _shadowColor;
  74432. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74433. get shadowColor(): string;
  74434. set shadowColor(value: string);
  74435. /** Gets or sets the cursor to use when the control is hovered */
  74436. hoverCursor: string;
  74437. /** @hidden */
  74438. protected _linkOffsetX: ValueAndUnit;
  74439. /** @hidden */
  74440. protected _linkOffsetY: ValueAndUnit;
  74441. /** Gets the control type name */
  74442. get typeName(): string;
  74443. /**
  74444. * Get the current class name of the control.
  74445. * @returns current class name
  74446. */
  74447. getClassName(): string;
  74448. /**
  74449. * An event triggered when pointer wheel is scrolled
  74450. */
  74451. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74452. /**
  74453. * An event triggered when the pointer move over the control.
  74454. */
  74455. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74456. /**
  74457. * An event triggered when the pointer move out of the control.
  74458. */
  74459. onPointerOutObservable: BABYLON.Observable<Control>;
  74460. /**
  74461. * An event triggered when the pointer taps the control
  74462. */
  74463. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74464. /**
  74465. * An event triggered when pointer up
  74466. */
  74467. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74468. /**
  74469. * An event triggered when a control is clicked on
  74470. */
  74471. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74472. /**
  74473. * An event triggered when pointer enters the control
  74474. */
  74475. onPointerEnterObservable: BABYLON.Observable<Control>;
  74476. /**
  74477. * An event triggered when the control is marked as dirty
  74478. */
  74479. onDirtyObservable: BABYLON.Observable<Control>;
  74480. /**
  74481. * An event triggered before drawing the control
  74482. */
  74483. onBeforeDrawObservable: BABYLON.Observable<Control>;
  74484. /**
  74485. * An event triggered after the control was drawn
  74486. */
  74487. onAfterDrawObservable: BABYLON.Observable<Control>;
  74488. /**
  74489. * An event triggered when the control has been disposed
  74490. */
  74491. onDisposeObservable: BABYLON.Observable<Control>;
  74492. /**
  74493. * Get the hosting AdvancedDynamicTexture
  74494. */
  74495. get host(): AdvancedDynamicTexture;
  74496. /** Gets or set information about font offsets (used to render and align text) */
  74497. get fontOffset(): {
  74498. ascent: number;
  74499. height: number;
  74500. descent: number;
  74501. };
  74502. set fontOffset(offset: {
  74503. ascent: number;
  74504. height: number;
  74505. descent: number;
  74506. });
  74507. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  74508. get alpha(): number;
  74509. set alpha(value: number);
  74510. /**
  74511. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  74512. */
  74513. get isHighlighted(): boolean;
  74514. set isHighlighted(value: boolean);
  74515. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  74516. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74517. */
  74518. get scaleX(): number;
  74519. set scaleX(value: number);
  74520. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  74521. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74522. */
  74523. get scaleY(): number;
  74524. set scaleY(value: number);
  74525. /** Gets or sets the rotation angle (0 by default)
  74526. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74527. */
  74528. get rotation(): number;
  74529. set rotation(value: number);
  74530. /** Gets or sets the transformation center on Y axis (0 by default)
  74531. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74532. */
  74533. get transformCenterY(): number;
  74534. set transformCenterY(value: number);
  74535. /** Gets or sets the transformation center on X axis (0 by default)
  74536. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  74537. */
  74538. get transformCenterX(): number;
  74539. set transformCenterX(value: number);
  74540. /**
  74541. * Gets or sets the horizontal alignment
  74542. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74543. */
  74544. get horizontalAlignment(): number;
  74545. set horizontalAlignment(value: number);
  74546. /**
  74547. * Gets or sets the vertical alignment
  74548. * @see http://doc.babylonjs.com/how_to/gui#alignments
  74549. */
  74550. get verticalAlignment(): number;
  74551. set verticalAlignment(value: number);
  74552. /**
  74553. * Gets or sets control width
  74554. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74555. */
  74556. get width(): string | number;
  74557. set width(value: string | number);
  74558. /**
  74559. * Gets or sets the control width in pixel
  74560. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74561. */
  74562. get widthInPixels(): number;
  74563. set widthInPixels(value: number);
  74564. /**
  74565. * Gets or sets control height
  74566. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74567. */
  74568. get height(): string | number;
  74569. set height(value: string | number);
  74570. /**
  74571. * Gets or sets control height in pixel
  74572. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74573. */
  74574. get heightInPixels(): number;
  74575. set heightInPixels(value: number);
  74576. /** Gets or set font family */
  74577. get fontFamily(): string;
  74578. set fontFamily(value: string);
  74579. /** Gets or sets font style */
  74580. get fontStyle(): string;
  74581. set fontStyle(value: string);
  74582. /** Gets or sets font weight */
  74583. get fontWeight(): string;
  74584. set fontWeight(value: string);
  74585. /**
  74586. * Gets or sets style
  74587. * @see http://doc.babylonjs.com/how_to/gui#styles
  74588. */
  74589. get style(): BABYLON.Nullable<Style>;
  74590. set style(value: BABYLON.Nullable<Style>);
  74591. /** @hidden */
  74592. get _isFontSizeInPercentage(): boolean;
  74593. /** Gets or sets font size in pixels */
  74594. get fontSizeInPixels(): number;
  74595. set fontSizeInPixels(value: number);
  74596. /** Gets or sets font size */
  74597. get fontSize(): string | number;
  74598. set fontSize(value: string | number);
  74599. /** Gets or sets foreground color */
  74600. get color(): string;
  74601. set color(value: string);
  74602. /** Gets or sets z index which is used to reorder controls on the z axis */
  74603. get zIndex(): number;
  74604. set zIndex(value: number);
  74605. /** Gets or sets a boolean indicating if the control can be rendered */
  74606. get notRenderable(): boolean;
  74607. set notRenderable(value: boolean);
  74608. /** Gets or sets a boolean indicating if the control is visible */
  74609. get isVisible(): boolean;
  74610. set isVisible(value: boolean);
  74611. /** Gets a boolean indicating that the control needs to update its rendering */
  74612. get isDirty(): boolean;
  74613. /**
  74614. * Gets the current linked mesh (or null if none)
  74615. */
  74616. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74617. /**
  74618. * Gets or sets a value indicating the padding to use on the left of the control
  74619. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74620. */
  74621. get paddingLeft(): string | number;
  74622. set paddingLeft(value: string | number);
  74623. /**
  74624. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  74625. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74626. */
  74627. get paddingLeftInPixels(): number;
  74628. set paddingLeftInPixels(value: number);
  74629. /**
  74630. * Gets or sets a value indicating the padding to use on the right of the control
  74631. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74632. */
  74633. get paddingRight(): string | number;
  74634. set paddingRight(value: string | number);
  74635. /**
  74636. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  74637. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74638. */
  74639. get paddingRightInPixels(): number;
  74640. set paddingRightInPixels(value: number);
  74641. /**
  74642. * Gets or sets a value indicating the padding to use on the top of the control
  74643. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74644. */
  74645. get paddingTop(): string | number;
  74646. set paddingTop(value: string | number);
  74647. /**
  74648. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  74649. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74650. */
  74651. get paddingTopInPixels(): number;
  74652. set paddingTopInPixels(value: number);
  74653. /**
  74654. * Gets or sets a value indicating the padding to use on the bottom of the control
  74655. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74656. */
  74657. get paddingBottom(): string | number;
  74658. set paddingBottom(value: string | number);
  74659. /**
  74660. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  74661. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74662. */
  74663. get paddingBottomInPixels(): number;
  74664. set paddingBottomInPixels(value: number);
  74665. /**
  74666. * Gets or sets a value indicating the left coordinate of the control
  74667. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74668. */
  74669. get left(): string | number;
  74670. set left(value: string | number);
  74671. /**
  74672. * Gets or sets a value indicating the left coordinate in pixels of the control
  74673. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74674. */
  74675. get leftInPixels(): number;
  74676. set leftInPixels(value: number);
  74677. /**
  74678. * Gets or sets a value indicating the top coordinate of the control
  74679. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74680. */
  74681. get top(): string | number;
  74682. set top(value: string | number);
  74683. /**
  74684. * Gets or sets a value indicating the top coordinate in pixels of the control
  74685. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74686. */
  74687. get topInPixels(): number;
  74688. set topInPixels(value: number);
  74689. /**
  74690. * Gets or sets a value indicating the offset on X axis to the linked mesh
  74691. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74692. */
  74693. get linkOffsetX(): string | number;
  74694. set linkOffsetX(value: string | number);
  74695. /**
  74696. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  74697. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74698. */
  74699. get linkOffsetXInPixels(): number;
  74700. set linkOffsetXInPixels(value: number);
  74701. /**
  74702. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  74703. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74704. */
  74705. get linkOffsetY(): string | number;
  74706. set linkOffsetY(value: string | number);
  74707. /**
  74708. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  74709. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74710. */
  74711. get linkOffsetYInPixels(): number;
  74712. set linkOffsetYInPixels(value: number);
  74713. /** Gets the center coordinate on X axis */
  74714. get centerX(): number;
  74715. /** Gets the center coordinate on Y axis */
  74716. get centerY(): number;
  74717. /** Gets or sets if control is Enabled*/
  74718. get isEnabled(): boolean;
  74719. set isEnabled(value: boolean);
  74720. /** Gets or sets background color of control if it's disabled*/
  74721. get disabledColor(): string;
  74722. set disabledColor(value: string);
  74723. /** Gets or sets front color of control if it's disabled*/
  74724. get disabledColorItem(): string;
  74725. set disabledColorItem(value: string);
  74726. /**
  74727. * Creates a new control
  74728. * @param name defines the name of the control
  74729. */
  74730. constructor(
  74731. /** defines the name of the control */
  74732. name?: string | undefined);
  74733. /** @hidden */
  74734. protected _getTypeName(): string;
  74735. /**
  74736. * Gets the first ascendant in the hierarchy of the given type
  74737. * @param className defines the required type
  74738. * @returns the ascendant or null if not found
  74739. */
  74740. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  74741. /** @hidden */
  74742. _resetFontCache(): void;
  74743. /**
  74744. * Determines if a container is an ascendant of the current control
  74745. * @param container defines the container to look for
  74746. * @returns true if the container is one of the ascendant of the control
  74747. */
  74748. isAscendant(container: Control): boolean;
  74749. /**
  74750. * Gets coordinates in local control space
  74751. * @param globalCoordinates defines the coordinates to transform
  74752. * @returns the new coordinates in local space
  74753. */
  74754. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74755. /**
  74756. * Gets coordinates in local control space
  74757. * @param globalCoordinates defines the coordinates to transform
  74758. * @param result defines the target vector2 where to store the result
  74759. * @returns the current control
  74760. */
  74761. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  74762. /**
  74763. * Gets coordinates in parent local control space
  74764. * @param globalCoordinates defines the coordinates to transform
  74765. * @returns the new coordinates in parent local space
  74766. */
  74767. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  74768. /**
  74769. * Move the current control to a vector3 position projected onto the screen.
  74770. * @param position defines the target position
  74771. * @param scene defines the hosting scene
  74772. */
  74773. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  74774. /**
  74775. * Will store all controls that have this control as ascendant in a given array
  74776. * @param results defines the array where to store the descendants
  74777. * @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
  74778. * @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
  74779. */
  74780. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  74781. /**
  74782. * Will return all controls that have this control as ascendant
  74783. * @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
  74784. * @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
  74785. * @return all child controls
  74786. */
  74787. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74788. /**
  74789. * Link current control with a target mesh
  74790. * @param mesh defines the mesh to link with
  74791. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  74792. */
  74793. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  74794. /** @hidden */
  74795. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  74796. /** @hidden */
  74797. _offsetLeft(offset: number): void;
  74798. /** @hidden */
  74799. _offsetTop(offset: number): void;
  74800. /** @hidden */
  74801. _markMatrixAsDirty(): void;
  74802. /** @hidden */
  74803. _flagDescendantsAsMatrixDirty(): void;
  74804. /** @hidden */
  74805. _intersectsRect(rect: Measure): boolean;
  74806. /** @hidden */
  74807. protected invalidateRect(): void;
  74808. /** @hidden */
  74809. _markAsDirty(force?: boolean): void;
  74810. /** @hidden */
  74811. _markAllAsDirty(): void;
  74812. /** @hidden */
  74813. _link(host: AdvancedDynamicTexture): void;
  74814. /** @hidden */
  74815. protected _transform(context?: CanvasRenderingContext2D): void;
  74816. /** @hidden */
  74817. _renderHighlight(context: CanvasRenderingContext2D): void;
  74818. /** @hidden */
  74819. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74820. /** @hidden */
  74821. protected _applyStates(context: CanvasRenderingContext2D): void;
  74822. /** @hidden */
  74823. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  74824. /** @hidden */
  74825. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74826. protected _evaluateClippingState(parentMeasure: Measure): void;
  74827. /** @hidden */
  74828. _measure(): void;
  74829. /** @hidden */
  74830. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74831. /** @hidden */
  74832. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74833. /** @hidden */
  74834. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74835. /** @hidden */
  74836. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74837. private static _ClipMeasure;
  74838. private _tmpMeasureA;
  74839. private _clip;
  74840. /** @hidden */
  74841. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  74842. /** @hidden */
  74843. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74844. /**
  74845. * Tests if a given coordinates belong to the current control
  74846. * @param x defines x coordinate to test
  74847. * @param y defines y coordinate to test
  74848. * @returns true if the coordinates are inside the control
  74849. */
  74850. contains(x: number, y: number): boolean;
  74851. /** @hidden */
  74852. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74853. /** @hidden */
  74854. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74855. /** @hidden */
  74856. _onPointerEnter(target: Control): boolean;
  74857. /** @hidden */
  74858. _onPointerOut(target: Control, force?: boolean): void;
  74859. /** @hidden */
  74860. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74861. /** @hidden */
  74862. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74863. /** @hidden */
  74864. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74865. /** @hidden */
  74866. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  74867. /** @hidden */
  74868. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74869. private _prepareFont;
  74870. /** Releases associated resources */
  74871. dispose(): void;
  74872. private static _HORIZONTAL_ALIGNMENT_LEFT;
  74873. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  74874. private static _HORIZONTAL_ALIGNMENT_CENTER;
  74875. private static _VERTICAL_ALIGNMENT_TOP;
  74876. private static _VERTICAL_ALIGNMENT_BOTTOM;
  74877. private static _VERTICAL_ALIGNMENT_CENTER;
  74878. /** HORIZONTAL_ALIGNMENT_LEFT */
  74879. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  74880. /** HORIZONTAL_ALIGNMENT_RIGHT */
  74881. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  74882. /** HORIZONTAL_ALIGNMENT_CENTER */
  74883. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  74884. /** VERTICAL_ALIGNMENT_TOP */
  74885. static get VERTICAL_ALIGNMENT_TOP(): number;
  74886. /** VERTICAL_ALIGNMENT_BOTTOM */
  74887. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  74888. /** VERTICAL_ALIGNMENT_CENTER */
  74889. static get VERTICAL_ALIGNMENT_CENTER(): number;
  74890. private static _FontHeightSizes;
  74891. /** @hidden */
  74892. static _GetFontOffset(font: string): {
  74893. ascent: number;
  74894. height: number;
  74895. descent: number;
  74896. };
  74897. /**
  74898. * Creates a stack panel that can be used to render headers
  74899. * @param control defines the control to associate with the header
  74900. * @param text defines the text of the header
  74901. * @param size defines the size of the header
  74902. * @param options defines options used to configure the header
  74903. * @returns a new StackPanel
  74904. * @ignore
  74905. * @hidden
  74906. */
  74907. static AddHeader: (control: Control, text: string, size: string | number, options: {
  74908. isHorizontal: boolean;
  74909. controlFirst: boolean;
  74910. }) => any;
  74911. /** @hidden */
  74912. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  74913. }
  74914. }
  74915. declare module BABYLON.GUI {
  74916. /**
  74917. * Root class for 2D containers
  74918. * @see http://doc.babylonjs.com/how_to/gui#containers
  74919. */
  74920. export class Container extends Control {
  74921. name?: string | undefined;
  74922. /** @hidden */
  74923. _children: Control[];
  74924. /** @hidden */
  74925. protected _measureForChildren: Measure;
  74926. /** @hidden */
  74927. protected _background: string;
  74928. /** @hidden */
  74929. protected _adaptWidthToChildren: boolean;
  74930. /** @hidden */
  74931. protected _adaptHeightToChildren: boolean;
  74932. /**
  74933. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  74934. */
  74935. logLayoutCycleErrors: boolean;
  74936. /**
  74937. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  74938. */
  74939. maxLayoutCycle: number;
  74940. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  74941. get adaptHeightToChildren(): boolean;
  74942. set adaptHeightToChildren(value: boolean);
  74943. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  74944. get adaptWidthToChildren(): boolean;
  74945. set adaptWidthToChildren(value: boolean);
  74946. /** Gets or sets background color */
  74947. get background(): string;
  74948. set background(value: string);
  74949. /** Gets the list of children */
  74950. get children(): Control[];
  74951. /**
  74952. * Creates a new Container
  74953. * @param name defines the name of the container
  74954. */
  74955. constructor(name?: string | undefined);
  74956. protected _getTypeName(): string;
  74957. _flagDescendantsAsMatrixDirty(): void;
  74958. /**
  74959. * Gets a child using its name
  74960. * @param name defines the child name to look for
  74961. * @returns the child control if found
  74962. */
  74963. getChildByName(name: string): BABYLON.Nullable<Control>;
  74964. /**
  74965. * Gets a child using its type and its name
  74966. * @param name defines the child name to look for
  74967. * @param type defines the child type to look for
  74968. * @returns the child control if found
  74969. */
  74970. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  74971. /**
  74972. * Search for a specific control in children
  74973. * @param control defines the control to look for
  74974. * @returns true if the control is in child list
  74975. */
  74976. containsControl(control: Control): boolean;
  74977. /**
  74978. * Adds a new control to the current container
  74979. * @param control defines the control to add
  74980. * @returns the current container
  74981. */
  74982. addControl(control: BABYLON.Nullable<Control>): Container;
  74983. /**
  74984. * Removes all controls from the current container
  74985. * @returns the current container
  74986. */
  74987. clearControls(): Container;
  74988. /**
  74989. * Removes a control from the current container
  74990. * @param control defines the control to remove
  74991. * @returns the current container
  74992. */
  74993. removeControl(control: Control): Container;
  74994. /** @hidden */
  74995. _reOrderControl(control: Control): void;
  74996. /** @hidden */
  74997. _offsetLeft(offset: number): void;
  74998. /** @hidden */
  74999. _offsetTop(offset: number): void;
  75000. /** @hidden */
  75001. _markAllAsDirty(): void;
  75002. /** @hidden */
  75003. protected _localDraw(context: CanvasRenderingContext2D): void;
  75004. /** @hidden */
  75005. _link(host: AdvancedDynamicTexture): void;
  75006. /** @hidden */
  75007. protected _beforeLayout(): void;
  75008. /** @hidden */
  75009. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75010. /** @hidden */
  75011. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75012. protected _postMeasure(): void;
  75013. /** @hidden */
  75014. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75015. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75016. /** @hidden */
  75017. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75018. /** @hidden */
  75019. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75020. /** Releases associated resources */
  75021. dispose(): void;
  75022. }
  75023. }
  75024. declare module BABYLON.GUI {
  75025. /** Class used to create rectangle container */
  75026. export class Rectangle extends Container {
  75027. name?: string | undefined;
  75028. private _thickness;
  75029. private _cornerRadius;
  75030. /** Gets or sets border thickness */
  75031. get thickness(): number;
  75032. set thickness(value: number);
  75033. /** Gets or sets the corner radius angle */
  75034. get cornerRadius(): number;
  75035. set cornerRadius(value: number);
  75036. /**
  75037. * Creates a new Rectangle
  75038. * @param name defines the control name
  75039. */
  75040. constructor(name?: string | undefined);
  75041. protected _getTypeName(): string;
  75042. protected _localDraw(context: CanvasRenderingContext2D): void;
  75043. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75044. private _drawRoundedRect;
  75045. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75046. }
  75047. }
  75048. declare module BABYLON.GUI {
  75049. /**
  75050. * Enum that determines the text-wrapping mode to use.
  75051. */
  75052. export enum TextWrapping {
  75053. /**
  75054. * Clip the text when it's larger than Control.width; this is the default mode.
  75055. */
  75056. Clip = 0,
  75057. /**
  75058. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  75059. */
  75060. WordWrap = 1,
  75061. /**
  75062. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  75063. */
  75064. Ellipsis = 2
  75065. }
  75066. /**
  75067. * Class used to create text block control
  75068. */
  75069. export class TextBlock extends Control {
  75070. /**
  75071. * Defines the name of the control
  75072. */
  75073. name?: string | undefined;
  75074. private _text;
  75075. private _textWrapping;
  75076. private _textHorizontalAlignment;
  75077. private _textVerticalAlignment;
  75078. private _lines;
  75079. private _resizeToFit;
  75080. private _lineSpacing;
  75081. private _outlineWidth;
  75082. private _outlineColor;
  75083. /**
  75084. * An event triggered after the text is changed
  75085. */
  75086. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  75087. /**
  75088. * An event triggered after the text was broken up into lines
  75089. */
  75090. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  75091. /**
  75092. * Function used to split a string into words. By default, a string is split at each space character found
  75093. */
  75094. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  75095. /**
  75096. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  75097. */
  75098. get lines(): any[];
  75099. /**
  75100. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75101. */
  75102. get resizeToFit(): boolean;
  75103. /**
  75104. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75105. */
  75106. set resizeToFit(value: boolean);
  75107. /**
  75108. * Gets or sets a boolean indicating if text must be wrapped
  75109. */
  75110. get textWrapping(): TextWrapping | boolean;
  75111. /**
  75112. * Gets or sets a boolean indicating if text must be wrapped
  75113. */
  75114. set textWrapping(value: TextWrapping | boolean);
  75115. /**
  75116. * Gets or sets text to display
  75117. */
  75118. get text(): string;
  75119. /**
  75120. * Gets or sets text to display
  75121. */
  75122. set text(value: string);
  75123. /**
  75124. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75125. */
  75126. get textHorizontalAlignment(): number;
  75127. /**
  75128. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75129. */
  75130. set textHorizontalAlignment(value: number);
  75131. /**
  75132. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75133. */
  75134. get textVerticalAlignment(): number;
  75135. /**
  75136. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75137. */
  75138. set textVerticalAlignment(value: number);
  75139. /**
  75140. * Gets or sets line spacing value
  75141. */
  75142. set lineSpacing(value: string | number);
  75143. /**
  75144. * Gets or sets line spacing value
  75145. */
  75146. get lineSpacing(): string | number;
  75147. /**
  75148. * Gets or sets outlineWidth of the text to display
  75149. */
  75150. get outlineWidth(): number;
  75151. /**
  75152. * Gets or sets outlineWidth of the text to display
  75153. */
  75154. set outlineWidth(value: number);
  75155. /**
  75156. * Gets or sets outlineColor of the text to display
  75157. */
  75158. get outlineColor(): string;
  75159. /**
  75160. * Gets or sets outlineColor of the text to display
  75161. */
  75162. set outlineColor(value: string);
  75163. /**
  75164. * Creates a new TextBlock object
  75165. * @param name defines the name of the control
  75166. * @param text defines the text to display (emptry string by default)
  75167. */
  75168. constructor(
  75169. /**
  75170. * Defines the name of the control
  75171. */
  75172. name?: string | undefined, text?: string);
  75173. protected _getTypeName(): string;
  75174. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75175. private _drawText;
  75176. /** @hidden */
  75177. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75178. protected _applyStates(context: CanvasRenderingContext2D): void;
  75179. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75180. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75181. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75182. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75183. protected _renderLines(context: CanvasRenderingContext2D): void;
  75184. /**
  75185. * Given a width constraint applied on the text block, find the expected height
  75186. * @returns expected height
  75187. */
  75188. computeExpectedHeight(): number;
  75189. dispose(): void;
  75190. }
  75191. }
  75192. declare module BABYLON.GUI {
  75193. /**
  75194. * Class used to create 2D images
  75195. */
  75196. export class Image extends Control {
  75197. name?: string | undefined;
  75198. private _workingCanvas;
  75199. private _domImage;
  75200. private _imageWidth;
  75201. private _imageHeight;
  75202. private _loaded;
  75203. private _stretch;
  75204. private _source;
  75205. private _autoScale;
  75206. private _sourceLeft;
  75207. private _sourceTop;
  75208. private _sourceWidth;
  75209. private _sourceHeight;
  75210. private _svgAttributesComputationCompleted;
  75211. private _isSVG;
  75212. private _cellWidth;
  75213. private _cellHeight;
  75214. private _cellId;
  75215. private _populateNinePatchSlicesFromImage;
  75216. private _sliceLeft;
  75217. private _sliceRight;
  75218. private _sliceTop;
  75219. private _sliceBottom;
  75220. private _detectPointerOnOpaqueOnly;
  75221. /**
  75222. * BABYLON.Observable notified when the content is loaded
  75223. */
  75224. onImageLoadedObservable: BABYLON.Observable<Image>;
  75225. /**
  75226. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75227. */
  75228. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75229. /**
  75230. * Gets a boolean indicating that the content is loaded
  75231. */
  75232. get isLoaded(): boolean;
  75233. /**
  75234. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75235. */
  75236. get populateNinePatchSlicesFromImage(): boolean;
  75237. set populateNinePatchSlicesFromImage(value: boolean);
  75238. /**
  75239. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75240. * Beware using this as this will comsume more memory as the image has to be stored twice
  75241. */
  75242. get detectPointerOnOpaqueOnly(): boolean;
  75243. set detectPointerOnOpaqueOnly(value: boolean);
  75244. /**
  75245. * Gets or sets the left value for slicing (9-patch)
  75246. */
  75247. get sliceLeft(): number;
  75248. set sliceLeft(value: number);
  75249. /**
  75250. * Gets or sets the right value for slicing (9-patch)
  75251. */
  75252. get sliceRight(): number;
  75253. set sliceRight(value: number);
  75254. /**
  75255. * Gets or sets the top value for slicing (9-patch)
  75256. */
  75257. get sliceTop(): number;
  75258. set sliceTop(value: number);
  75259. /**
  75260. * Gets or sets the bottom value for slicing (9-patch)
  75261. */
  75262. get sliceBottom(): number;
  75263. set sliceBottom(value: number);
  75264. /**
  75265. * Gets or sets the left coordinate in the source image
  75266. */
  75267. get sourceLeft(): number;
  75268. set sourceLeft(value: number);
  75269. /**
  75270. * Gets or sets the top coordinate in the source image
  75271. */
  75272. get sourceTop(): number;
  75273. set sourceTop(value: number);
  75274. /**
  75275. * Gets or sets the width to capture in the source image
  75276. */
  75277. get sourceWidth(): number;
  75278. set sourceWidth(value: number);
  75279. /**
  75280. * Gets or sets the height to capture in the source image
  75281. */
  75282. get sourceHeight(): number;
  75283. set sourceHeight(value: number);
  75284. /** Indicates if the format of the image is SVG */
  75285. get isSVG(): boolean;
  75286. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75287. get svgAttributesComputationCompleted(): boolean;
  75288. /**
  75289. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75290. * @see http://doc.babylonjs.com/how_to/gui#image
  75291. */
  75292. get autoScale(): boolean;
  75293. set autoScale(value: boolean);
  75294. /** Gets or sets the streching mode used by the image */
  75295. get stretch(): number;
  75296. set stretch(value: number);
  75297. /** @hidden */
  75298. _rotate90(n: number, preserveProperties?: boolean): Image;
  75299. private _handleRotationForSVGImage;
  75300. private _rotate90SourceProperties;
  75301. /**
  75302. * Gets or sets the internal DOM image used to render the control
  75303. */
  75304. set domImage(value: HTMLImageElement);
  75305. get domImage(): HTMLImageElement;
  75306. private _onImageLoaded;
  75307. private _extractNinePatchSliceDataFromImage;
  75308. /**
  75309. * Gets or sets image source url
  75310. */
  75311. set source(value: BABYLON.Nullable<string>);
  75312. /**
  75313. * Checks for svg document with icon id present
  75314. */
  75315. private _svgCheck;
  75316. /**
  75317. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75318. * given external svg file and icon id
  75319. */
  75320. private _getSVGAttribs;
  75321. /**
  75322. * Gets or sets the cell width to use when animation sheet is enabled
  75323. * @see http://doc.babylonjs.com/how_to/gui#image
  75324. */
  75325. get cellWidth(): number;
  75326. set cellWidth(value: number);
  75327. /**
  75328. * Gets or sets the cell height to use when animation sheet is enabled
  75329. * @see http://doc.babylonjs.com/how_to/gui#image
  75330. */
  75331. get cellHeight(): number;
  75332. set cellHeight(value: number);
  75333. /**
  75334. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75335. * @see http://doc.babylonjs.com/how_to/gui#image
  75336. */
  75337. get cellId(): number;
  75338. set cellId(value: number);
  75339. /**
  75340. * Creates a new Image
  75341. * @param name defines the control name
  75342. * @param url defines the image url
  75343. */
  75344. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75345. /**
  75346. * Tests if a given coordinates belong to the current control
  75347. * @param x defines x coordinate to test
  75348. * @param y defines y coordinate to test
  75349. * @returns true if the coordinates are inside the control
  75350. */
  75351. contains(x: number, y: number): boolean;
  75352. protected _getTypeName(): string;
  75353. /** Force the control to synchronize with its content */
  75354. synchronizeSizeWithContent(): void;
  75355. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75356. private _prepareWorkingCanvasForOpaqueDetection;
  75357. private _drawImage;
  75358. _draw(context: CanvasRenderingContext2D): void;
  75359. private _renderCornerPatch;
  75360. private _renderNinePatch;
  75361. dispose(): void;
  75362. /** STRETCH_NONE */
  75363. static readonly STRETCH_NONE: number;
  75364. /** STRETCH_FILL */
  75365. static readonly STRETCH_FILL: number;
  75366. /** STRETCH_UNIFORM */
  75367. static readonly STRETCH_UNIFORM: number;
  75368. /** STRETCH_EXTEND */
  75369. static readonly STRETCH_EXTEND: number;
  75370. /** NINE_PATCH */
  75371. static readonly STRETCH_NINE_PATCH: number;
  75372. }
  75373. }
  75374. declare module BABYLON.GUI {
  75375. /**
  75376. * Class used to create 2D buttons
  75377. */
  75378. export class Button extends Rectangle {
  75379. name?: string | undefined;
  75380. /**
  75381. * Function called to generate a pointer enter animation
  75382. */
  75383. pointerEnterAnimation: () => void;
  75384. /**
  75385. * Function called to generate a pointer out animation
  75386. */
  75387. pointerOutAnimation: () => void;
  75388. /**
  75389. * Function called to generate a pointer down animation
  75390. */
  75391. pointerDownAnimation: () => void;
  75392. /**
  75393. * Function called to generate a pointer up animation
  75394. */
  75395. pointerUpAnimation: () => void;
  75396. /**
  75397. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75398. */
  75399. delegatePickingToChildren: boolean;
  75400. private _image;
  75401. /**
  75402. * Returns the image part of the button (if any)
  75403. */
  75404. get image(): BABYLON.Nullable<Image>;
  75405. private _textBlock;
  75406. /**
  75407. * Returns the image part of the button (if any)
  75408. */
  75409. get textBlock(): BABYLON.Nullable<TextBlock>;
  75410. /**
  75411. * Creates a new Button
  75412. * @param name defines the name of the button
  75413. */
  75414. constructor(name?: string | undefined);
  75415. protected _getTypeName(): string;
  75416. /** @hidden */
  75417. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75418. /** @hidden */
  75419. _onPointerEnter(target: Control): boolean;
  75420. /** @hidden */
  75421. _onPointerOut(target: Control, force?: boolean): void;
  75422. /** @hidden */
  75423. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75424. /** @hidden */
  75425. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75426. /**
  75427. * Creates a new button made with an image and a text
  75428. * @param name defines the name of the button
  75429. * @param text defines the text of the button
  75430. * @param imageUrl defines the url of the image
  75431. * @returns a new Button
  75432. */
  75433. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75434. /**
  75435. * Creates a new button made with an image
  75436. * @param name defines the name of the button
  75437. * @param imageUrl defines the url of the image
  75438. * @returns a new Button
  75439. */
  75440. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75441. /**
  75442. * Creates a new button made with a text
  75443. * @param name defines the name of the button
  75444. * @param text defines the text of the button
  75445. * @returns a new Button
  75446. */
  75447. static CreateSimpleButton(name: string, text: string): Button;
  75448. /**
  75449. * Creates a new button made with an image and a centered text
  75450. * @param name defines the name of the button
  75451. * @param text defines the text of the button
  75452. * @param imageUrl defines the url of the image
  75453. * @returns a new Button
  75454. */
  75455. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75456. }
  75457. }
  75458. declare module BABYLON.GUI {
  75459. /**
  75460. * Class used to create a 2D stack panel container
  75461. */
  75462. export class StackPanel extends Container {
  75463. name?: string | undefined;
  75464. private _isVertical;
  75465. private _manualWidth;
  75466. private _manualHeight;
  75467. private _doNotTrackManualChanges;
  75468. /**
  75469. * Gets or sets a boolean indicating that layou warnings should be ignored
  75470. */
  75471. ignoreLayoutWarnings: boolean;
  75472. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75473. get isVertical(): boolean;
  75474. set isVertical(value: boolean);
  75475. /**
  75476. * Gets or sets panel width.
  75477. * This value should not be set when in horizontal mode as it will be computed automatically
  75478. */
  75479. set width(value: string | number);
  75480. get width(): string | number;
  75481. /**
  75482. * Gets or sets panel height.
  75483. * This value should not be set when in vertical mode as it will be computed automatically
  75484. */
  75485. set height(value: string | number);
  75486. get height(): string | number;
  75487. /**
  75488. * Creates a new StackPanel
  75489. * @param name defines control name
  75490. */
  75491. constructor(name?: string | undefined);
  75492. protected _getTypeName(): string;
  75493. /** @hidden */
  75494. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75495. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75496. protected _postMeasure(): void;
  75497. }
  75498. }
  75499. declare module BABYLON.GUI {
  75500. /**
  75501. * Class used to represent a 2D checkbox
  75502. */
  75503. export class Checkbox extends Control {
  75504. name?: string | undefined;
  75505. private _isChecked;
  75506. private _background;
  75507. private _checkSizeRatio;
  75508. private _thickness;
  75509. /** Gets or sets border thickness */
  75510. get thickness(): number;
  75511. set thickness(value: number);
  75512. /**
  75513. * BABYLON.Observable raised when isChecked property changes
  75514. */
  75515. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75516. /** Gets or sets a value indicating the ratio between overall size and check size */
  75517. get checkSizeRatio(): number;
  75518. set checkSizeRatio(value: number);
  75519. /** Gets or sets background color */
  75520. get background(): string;
  75521. set background(value: string);
  75522. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75523. get isChecked(): boolean;
  75524. set isChecked(value: boolean);
  75525. /**
  75526. * Creates a new CheckBox
  75527. * @param name defines the control name
  75528. */
  75529. constructor(name?: string | undefined);
  75530. protected _getTypeName(): string;
  75531. /** @hidden */
  75532. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75533. /** @hidden */
  75534. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75535. /**
  75536. * Utility function to easily create a checkbox with a header
  75537. * @param title defines the label to use for the header
  75538. * @param onValueChanged defines the callback to call when value changes
  75539. * @returns a StackPanel containing the checkbox and a textBlock
  75540. */
  75541. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  75542. }
  75543. }
  75544. declare module BABYLON.GUI {
  75545. /**
  75546. * Class used to store key control properties
  75547. */
  75548. export class KeyPropertySet {
  75549. /** Width */
  75550. width?: string;
  75551. /** Height */
  75552. height?: string;
  75553. /** Left padding */
  75554. paddingLeft?: string;
  75555. /** Right padding */
  75556. paddingRight?: string;
  75557. /** Top padding */
  75558. paddingTop?: string;
  75559. /** Bottom padding */
  75560. paddingBottom?: string;
  75561. /** Foreground color */
  75562. color?: string;
  75563. /** Background color */
  75564. background?: string;
  75565. }
  75566. /**
  75567. * Class used to create virtual keyboard
  75568. */
  75569. export class VirtualKeyboard extends StackPanel {
  75570. /** BABYLON.Observable raised when a key is pressed */
  75571. onKeyPressObservable: BABYLON.Observable<string>;
  75572. /** Gets or sets default key button width */
  75573. defaultButtonWidth: string;
  75574. /** Gets or sets default key button height */
  75575. defaultButtonHeight: string;
  75576. /** Gets or sets default key button left padding */
  75577. defaultButtonPaddingLeft: string;
  75578. /** Gets or sets default key button right padding */
  75579. defaultButtonPaddingRight: string;
  75580. /** Gets or sets default key button top padding */
  75581. defaultButtonPaddingTop: string;
  75582. /** Gets or sets default key button bottom padding */
  75583. defaultButtonPaddingBottom: string;
  75584. /** Gets or sets default key button foreground color */
  75585. defaultButtonColor: string;
  75586. /** Gets or sets default key button background color */
  75587. defaultButtonBackground: string;
  75588. /** Gets or sets shift button foreground color */
  75589. shiftButtonColor: string;
  75590. /** Gets or sets shift button thickness*/
  75591. selectedShiftThickness: number;
  75592. /** Gets shift key state */
  75593. shiftState: number;
  75594. protected _getTypeName(): string;
  75595. private _createKey;
  75596. /**
  75597. * Adds a new row of keys
  75598. * @param keys defines the list of keys to add
  75599. * @param propertySets defines the associated property sets
  75600. */
  75601. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  75602. /**
  75603. * Set the shift key to a specific state
  75604. * @param shiftState defines the new shift state
  75605. */
  75606. applyShiftState(shiftState: number): void;
  75607. private _currentlyConnectedInputText;
  75608. private _connectedInputTexts;
  75609. private _onKeyPressObserver;
  75610. /** Gets the input text control currently attached to the keyboard */
  75611. get connectedInputText(): BABYLON.Nullable<InputText>;
  75612. /**
  75613. * Connects the keyboard with an input text control
  75614. *
  75615. * @param input defines the target control
  75616. */
  75617. connect(input: InputText): void;
  75618. /**
  75619. * Disconnects the keyboard from connected InputText controls
  75620. *
  75621. * @param input optionally defines a target control, otherwise all are disconnected
  75622. */
  75623. disconnect(input?: InputText): void;
  75624. private _removeConnectedInputObservables;
  75625. /**
  75626. * Release all resources
  75627. */
  75628. dispose(): void;
  75629. /**
  75630. * Creates a new keyboard using a default layout
  75631. *
  75632. * @param name defines control name
  75633. * @returns a new VirtualKeyboard
  75634. */
  75635. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  75636. }
  75637. }
  75638. declare module BABYLON.GUI {
  75639. /**
  75640. * Class used to create input text control
  75641. */
  75642. export class InputText extends Control implements IFocusableControl {
  75643. name?: string | undefined;
  75644. private _text;
  75645. private _placeholderText;
  75646. private _background;
  75647. private _focusedBackground;
  75648. private _focusedColor;
  75649. private _placeholderColor;
  75650. private _thickness;
  75651. private _margin;
  75652. private _autoStretchWidth;
  75653. private _maxWidth;
  75654. private _isFocused;
  75655. private _blinkTimeout;
  75656. private _blinkIsEven;
  75657. private _cursorOffset;
  75658. private _scrollLeft;
  75659. private _textWidth;
  75660. private _clickedCoordinate;
  75661. private _deadKey;
  75662. private _addKey;
  75663. private _currentKey;
  75664. private _isTextHighlightOn;
  75665. private _textHighlightColor;
  75666. private _highligherOpacity;
  75667. private _highlightedText;
  75668. private _startHighlightIndex;
  75669. private _endHighlightIndex;
  75670. private _cursorIndex;
  75671. private _onFocusSelectAll;
  75672. private _isPointerDown;
  75673. private _onClipboardObserver;
  75674. private _onPointerDblTapObserver;
  75675. /** @hidden */
  75676. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  75677. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  75678. promptMessage: string;
  75679. /** Force disable prompt on mobile device */
  75680. disableMobilePrompt: boolean;
  75681. /** BABYLON.Observable raised when the text changes */
  75682. onTextChangedObservable: BABYLON.Observable<InputText>;
  75683. /** BABYLON.Observable raised just before an entered character is to be added */
  75684. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  75685. /** BABYLON.Observable raised when the control gets the focus */
  75686. onFocusObservable: BABYLON.Observable<InputText>;
  75687. /** BABYLON.Observable raised when the control loses the focus */
  75688. onBlurObservable: BABYLON.Observable<InputText>;
  75689. /**Observable raised when the text is highlighted */
  75690. onTextHighlightObservable: BABYLON.Observable<InputText>;
  75691. /**Observable raised when copy event is triggered */
  75692. onTextCopyObservable: BABYLON.Observable<InputText>;
  75693. /** BABYLON.Observable raised when cut event is triggered */
  75694. onTextCutObservable: BABYLON.Observable<InputText>;
  75695. /** BABYLON.Observable raised when paste event is triggered */
  75696. onTextPasteObservable: BABYLON.Observable<InputText>;
  75697. /** BABYLON.Observable raised when a key event was processed */
  75698. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  75699. /** Gets or sets the maximum width allowed by the control */
  75700. get maxWidth(): string | number;
  75701. /** Gets the maximum width allowed by the control in pixels */
  75702. get maxWidthInPixels(): number;
  75703. set maxWidth(value: string | number);
  75704. /** Gets or sets the text highlighter transparency; default: 0.4 */
  75705. get highligherOpacity(): number;
  75706. set highligherOpacity(value: number);
  75707. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  75708. get onFocusSelectAll(): boolean;
  75709. set onFocusSelectAll(value: boolean);
  75710. /** Gets or sets the text hightlight color */
  75711. get textHighlightColor(): string;
  75712. set textHighlightColor(value: string);
  75713. /** Gets or sets control margin */
  75714. get margin(): string;
  75715. /** Gets control margin in pixels */
  75716. get marginInPixels(): number;
  75717. set margin(value: string);
  75718. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  75719. get autoStretchWidth(): boolean;
  75720. set autoStretchWidth(value: boolean);
  75721. /** Gets or sets border thickness */
  75722. get thickness(): number;
  75723. set thickness(value: number);
  75724. /** Gets or sets the background color when focused */
  75725. get focusedBackground(): string;
  75726. set focusedBackground(value: string);
  75727. /** Gets or sets the background color when focused */
  75728. get focusedColor(): string;
  75729. set focusedColor(value: string);
  75730. /** Gets or sets the background color */
  75731. get background(): string;
  75732. set background(value: string);
  75733. /** Gets or sets the placeholder color */
  75734. get placeholderColor(): string;
  75735. set placeholderColor(value: string);
  75736. /** Gets or sets the text displayed when the control is empty */
  75737. get placeholderText(): string;
  75738. set placeholderText(value: string);
  75739. /** Gets or sets the dead key flag */
  75740. get deadKey(): boolean;
  75741. set deadKey(flag: boolean);
  75742. /** Gets or sets the highlight text */
  75743. get highlightedText(): string;
  75744. set highlightedText(text: string);
  75745. /** Gets or sets if the current key should be added */
  75746. get addKey(): boolean;
  75747. set addKey(flag: boolean);
  75748. /** Gets or sets the value of the current key being entered */
  75749. get currentKey(): string;
  75750. set currentKey(key: string);
  75751. /** Gets or sets the text displayed in the control */
  75752. get text(): string;
  75753. set text(value: string);
  75754. /** Gets or sets control width */
  75755. get width(): string | number;
  75756. set width(value: string | number);
  75757. /**
  75758. * Creates a new InputText
  75759. * @param name defines the control name
  75760. * @param text defines the text of the control
  75761. */
  75762. constructor(name?: string | undefined, text?: string);
  75763. /** @hidden */
  75764. onBlur(): void;
  75765. /** @hidden */
  75766. onFocus(): void;
  75767. protected _getTypeName(): string;
  75768. /**
  75769. * Function called to get the list of controls that should not steal the focus from this control
  75770. * @returns an array of controls
  75771. */
  75772. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75773. /** @hidden */
  75774. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  75775. /** @hidden */
  75776. private _updateValueFromCursorIndex;
  75777. /** @hidden */
  75778. private _processDblClick;
  75779. /** @hidden */
  75780. private _selectAllText;
  75781. /**
  75782. * Handles the keyboard event
  75783. * @param evt Defines the KeyboardEvent
  75784. */
  75785. processKeyboard(evt: KeyboardEvent): void;
  75786. /** @hidden */
  75787. private _onCopyText;
  75788. /** @hidden */
  75789. private _onCutText;
  75790. /** @hidden */
  75791. private _onPasteText;
  75792. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75793. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75794. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75795. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75796. protected _beforeRenderText(text: string): string;
  75797. dispose(): void;
  75798. }
  75799. }
  75800. declare module BABYLON.GUI {
  75801. /**
  75802. * Class used to create a 2D grid container
  75803. */
  75804. export class Grid extends Container {
  75805. name?: string | undefined;
  75806. private _rowDefinitions;
  75807. private _columnDefinitions;
  75808. private _cells;
  75809. private _childControls;
  75810. /**
  75811. * Gets the number of columns
  75812. */
  75813. get columnCount(): number;
  75814. /**
  75815. * Gets the number of rows
  75816. */
  75817. get rowCount(): number;
  75818. /** Gets the list of children */
  75819. get children(): Control[];
  75820. /** Gets the list of cells (e.g. the containers) */
  75821. get cells(): {
  75822. [key: string]: Container;
  75823. };
  75824. /**
  75825. * Gets the definition of a specific row
  75826. * @param index defines the index of the row
  75827. * @returns the row definition
  75828. */
  75829. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75830. /**
  75831. * Gets the definition of a specific column
  75832. * @param index defines the index of the column
  75833. * @returns the column definition
  75834. */
  75835. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  75836. /**
  75837. * Adds a new row to the grid
  75838. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75839. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  75840. * @returns the current grid
  75841. */
  75842. addRowDefinition(height: number, isPixel?: boolean): Grid;
  75843. /**
  75844. * Adds a new column to the grid
  75845. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75846. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75847. * @returns the current grid
  75848. */
  75849. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  75850. /**
  75851. * Update a row definition
  75852. * @param index defines the index of the row to update
  75853. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  75854. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  75855. * @returns the current grid
  75856. */
  75857. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  75858. /**
  75859. * Update a column definition
  75860. * @param index defines the index of the column to update
  75861. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  75862. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  75863. * @returns the current grid
  75864. */
  75865. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  75866. /**
  75867. * Gets the list of children stored in a specific cell
  75868. * @param row defines the row to check
  75869. * @param column defines the column to check
  75870. * @returns the list of controls
  75871. */
  75872. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  75873. /**
  75874. * Gets a string representing the child cell info (row x column)
  75875. * @param child defines the control to get info from
  75876. * @returns a string containing the child cell info (row x column)
  75877. */
  75878. getChildCellInfo(child: Control): string;
  75879. private _removeCell;
  75880. private _offsetCell;
  75881. /**
  75882. * Remove a column definition at specified index
  75883. * @param index defines the index of the column to remove
  75884. * @returns the current grid
  75885. */
  75886. removeColumnDefinition(index: number): Grid;
  75887. /**
  75888. * Remove a row definition at specified index
  75889. * @param index defines the index of the row to remove
  75890. * @returns the current grid
  75891. */
  75892. removeRowDefinition(index: number): Grid;
  75893. /**
  75894. * Adds a new control to the current grid
  75895. * @param control defines the control to add
  75896. * @param row defines the row where to add the control (0 by default)
  75897. * @param column defines the column where to add the control (0 by default)
  75898. * @returns the current grid
  75899. */
  75900. addControl(control: Control, row?: number, column?: number): Grid;
  75901. /**
  75902. * Removes a control from the current container
  75903. * @param control defines the control to remove
  75904. * @returns the current container
  75905. */
  75906. removeControl(control: Control): Container;
  75907. /**
  75908. * Creates a new Grid
  75909. * @param name defines control name
  75910. */
  75911. constructor(name?: string | undefined);
  75912. protected _getTypeName(): string;
  75913. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  75914. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75915. _flagDescendantsAsMatrixDirty(): void;
  75916. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75917. /** Releases associated resources */
  75918. dispose(): void;
  75919. }
  75920. }
  75921. declare module BABYLON.GUI {
  75922. /** Class used to create color pickers */
  75923. export class ColorPicker extends Control {
  75924. name?: string | undefined;
  75925. private static _Epsilon;
  75926. private _colorWheelCanvas;
  75927. private _value;
  75928. private _tmpColor;
  75929. private _pointerStartedOnSquare;
  75930. private _pointerStartedOnWheel;
  75931. private _squareLeft;
  75932. private _squareTop;
  75933. private _squareSize;
  75934. private _h;
  75935. private _s;
  75936. private _v;
  75937. private _lastPointerDownID;
  75938. /**
  75939. * BABYLON.Observable raised when the value changes
  75940. */
  75941. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  75942. /** Gets or sets the color of the color picker */
  75943. get value(): BABYLON.Color3;
  75944. set value(value: BABYLON.Color3);
  75945. /**
  75946. * Gets or sets control width
  75947. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75948. */
  75949. get width(): string | number;
  75950. set width(value: string | number);
  75951. /**
  75952. * Gets or sets control height
  75953. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75954. */
  75955. get height(): string | number;
  75956. /** Gets or sets control height */
  75957. set height(value: string | number);
  75958. /** Gets or sets control size */
  75959. get size(): string | number;
  75960. set size(value: string | number);
  75961. /**
  75962. * Creates a new ColorPicker
  75963. * @param name defines the control name
  75964. */
  75965. constructor(name?: string | undefined);
  75966. protected _getTypeName(): string;
  75967. /** @hidden */
  75968. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75969. private _updateSquareProps;
  75970. private _drawGradientSquare;
  75971. private _drawCircle;
  75972. private _createColorWheelCanvas;
  75973. /** @hidden */
  75974. _draw(context: CanvasRenderingContext2D): void;
  75975. private _pointerIsDown;
  75976. private _updateValueFromPointer;
  75977. private _isPointOnSquare;
  75978. private _isPointOnWheel;
  75979. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75980. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75981. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75982. /**
  75983. * This function expands the color picker by creating a color picker dialog with manual
  75984. * color value input and the ability to save colors into an array to be used later in
  75985. * subsequent launches of the dialogue.
  75986. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  75987. * @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.
  75988. * @returns picked color as a hex string and the saved colors array as hex strings.
  75989. */
  75990. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  75991. pickerWidth?: string;
  75992. pickerHeight?: string;
  75993. headerHeight?: string;
  75994. lastColor?: string;
  75995. swatchLimit?: number;
  75996. numSwatchesPerLine?: number;
  75997. savedColors?: Array<string>;
  75998. }): Promise<{
  75999. savedColors?: string[];
  76000. pickedColor: string;
  76001. }>;
  76002. }
  76003. }
  76004. declare module BABYLON.GUI {
  76005. /** Class used to create 2D ellipse containers */
  76006. export class Ellipse extends Container {
  76007. name?: string | undefined;
  76008. private _thickness;
  76009. /** Gets or sets border thickness */
  76010. get thickness(): number;
  76011. set thickness(value: number);
  76012. /**
  76013. * Creates a new Ellipse
  76014. * @param name defines the control name
  76015. */
  76016. constructor(name?: string | undefined);
  76017. protected _getTypeName(): string;
  76018. protected _localDraw(context: CanvasRenderingContext2D): void;
  76019. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76020. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76021. }
  76022. }
  76023. declare module BABYLON.GUI {
  76024. /**
  76025. * Class used to create a password control
  76026. */
  76027. export class InputPassword extends InputText {
  76028. protected _beforeRenderText(text: string): string;
  76029. }
  76030. }
  76031. declare module BABYLON.GUI {
  76032. /** Class used to render 2D lines */
  76033. export class Line extends Control {
  76034. name?: string | undefined;
  76035. private _lineWidth;
  76036. private _x1;
  76037. private _y1;
  76038. private _x2;
  76039. private _y2;
  76040. private _dash;
  76041. private _connectedControl;
  76042. private _connectedControlDirtyObserver;
  76043. /** Gets or sets the dash pattern */
  76044. get dash(): Array<number>;
  76045. set dash(value: Array<number>);
  76046. /** Gets or sets the control connected with the line end */
  76047. get connectedControl(): Control;
  76048. set connectedControl(value: Control);
  76049. /** Gets or sets start coordinates on X axis */
  76050. get x1(): string | number;
  76051. set x1(value: string | number);
  76052. /** Gets or sets start coordinates on Y axis */
  76053. get y1(): string | number;
  76054. set y1(value: string | number);
  76055. /** Gets or sets end coordinates on X axis */
  76056. get x2(): string | number;
  76057. set x2(value: string | number);
  76058. /** Gets or sets end coordinates on Y axis */
  76059. get y2(): string | number;
  76060. set y2(value: string | number);
  76061. /** Gets or sets line width */
  76062. get lineWidth(): number;
  76063. set lineWidth(value: number);
  76064. /** Gets or sets horizontal alignment */
  76065. set horizontalAlignment(value: number);
  76066. /** Gets or sets vertical alignment */
  76067. set verticalAlignment(value: number);
  76068. private get _effectiveX2();
  76069. private get _effectiveY2();
  76070. /**
  76071. * Creates a new Line
  76072. * @param name defines the control name
  76073. */
  76074. constructor(name?: string | undefined);
  76075. protected _getTypeName(): string;
  76076. _draw(context: CanvasRenderingContext2D): void;
  76077. _measure(): void;
  76078. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76079. /**
  76080. * Move one end of the line given 3D cartesian coordinates.
  76081. * @param position Targeted world position
  76082. * @param scene BABYLON.Scene
  76083. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76084. */
  76085. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  76086. /**
  76087. * Move one end of the line to a position in screen absolute space.
  76088. * @param projectedPosition Position in screen absolute space (X, Y)
  76089. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76090. */
  76091. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  76092. }
  76093. }
  76094. declare module BABYLON.GUI {
  76095. /**
  76096. * Class used to store a point for a MultiLine object.
  76097. * The point can be pure 2D coordinates, a mesh or a control
  76098. */
  76099. export class MultiLinePoint {
  76100. private _multiLine;
  76101. private _x;
  76102. private _y;
  76103. private _control;
  76104. private _mesh;
  76105. private _controlObserver;
  76106. private _meshObserver;
  76107. /** @hidden */
  76108. _point: BABYLON.Vector2;
  76109. /**
  76110. * Creates a new MultiLinePoint
  76111. * @param multiLine defines the source MultiLine object
  76112. */
  76113. constructor(multiLine: MultiLine);
  76114. /** Gets or sets x coordinate */
  76115. get x(): string | number;
  76116. set x(value: string | number);
  76117. /** Gets or sets y coordinate */
  76118. get y(): string | number;
  76119. set y(value: string | number);
  76120. /** Gets or sets the control associated with this point */
  76121. get control(): BABYLON.Nullable<Control>;
  76122. set control(value: BABYLON.Nullable<Control>);
  76123. /** Gets or sets the mesh associated with this point */
  76124. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76125. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  76126. /** Resets links */
  76127. resetLinks(): void;
  76128. /**
  76129. * Gets a translation vector
  76130. * @returns the translation vector
  76131. */
  76132. translate(): BABYLON.Vector2;
  76133. private _translatePoint;
  76134. /** Release associated resources */
  76135. dispose(): void;
  76136. }
  76137. }
  76138. declare module BABYLON.GUI {
  76139. /**
  76140. * Class used to create multi line control
  76141. */
  76142. export class MultiLine extends Control {
  76143. name?: string | undefined;
  76144. private _lineWidth;
  76145. private _dash;
  76146. private _points;
  76147. private _minX;
  76148. private _minY;
  76149. private _maxX;
  76150. private _maxY;
  76151. /**
  76152. * Creates a new MultiLine
  76153. * @param name defines the control name
  76154. */
  76155. constructor(name?: string | undefined);
  76156. /** Gets or sets dash pattern */
  76157. get dash(): Array<number>;
  76158. set dash(value: Array<number>);
  76159. /**
  76160. * Gets point stored at specified index
  76161. * @param index defines the index to look for
  76162. * @returns the requested point if found
  76163. */
  76164. getAt(index: number): MultiLinePoint;
  76165. /** Function called when a point is updated */
  76166. onPointUpdate: () => void;
  76167. /**
  76168. * Adds new points to the point collection
  76169. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76170. * @returns the list of created MultiLinePoint
  76171. */
  76172. add(...items: (AbstractMesh | Control | {
  76173. x: string | number;
  76174. y: string | number;
  76175. })[]): MultiLinePoint[];
  76176. /**
  76177. * Adds a new point to the point collection
  76178. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76179. * @returns the created MultiLinePoint
  76180. */
  76181. push(item?: (AbstractMesh | Control | {
  76182. x: string | number;
  76183. y: string | number;
  76184. })): MultiLinePoint;
  76185. /**
  76186. * Remove a specific value or point from the active point collection
  76187. * @param value defines the value or point to remove
  76188. */
  76189. remove(value: number | MultiLinePoint): void;
  76190. /**
  76191. * Resets this object to initial state (no point)
  76192. */
  76193. reset(): void;
  76194. /**
  76195. * Resets all links
  76196. */
  76197. resetLinks(): void;
  76198. /** Gets or sets line width */
  76199. get lineWidth(): number;
  76200. set lineWidth(value: number);
  76201. set horizontalAlignment(value: number);
  76202. set verticalAlignment(value: number);
  76203. protected _getTypeName(): string;
  76204. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76205. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76206. _measure(): void;
  76207. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76208. dispose(): void;
  76209. }
  76210. }
  76211. declare module BABYLON.GUI {
  76212. /**
  76213. * Class used to create radio button controls
  76214. */
  76215. export class RadioButton extends Control {
  76216. name?: string | undefined;
  76217. private _isChecked;
  76218. private _background;
  76219. private _checkSizeRatio;
  76220. private _thickness;
  76221. /** Gets or sets border thickness */
  76222. get thickness(): number;
  76223. set thickness(value: number);
  76224. /** Gets or sets group name */
  76225. group: string;
  76226. /** BABYLON.Observable raised when isChecked is changed */
  76227. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76228. /** Gets or sets a value indicating the ratio between overall size and check size */
  76229. get checkSizeRatio(): number;
  76230. set checkSizeRatio(value: number);
  76231. /** Gets or sets background color */
  76232. get background(): string;
  76233. set background(value: string);
  76234. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76235. get isChecked(): boolean;
  76236. set isChecked(value: boolean);
  76237. /**
  76238. * Creates a new RadioButton
  76239. * @param name defines the control name
  76240. */
  76241. constructor(name?: string | undefined);
  76242. protected _getTypeName(): string;
  76243. _draw(context: CanvasRenderingContext2D): void;
  76244. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76245. /**
  76246. * Utility function to easily create a radio button with a header
  76247. * @param title defines the label to use for the header
  76248. * @param group defines the group to use for the radio button
  76249. * @param isChecked defines the initial state of the radio button
  76250. * @param onValueChanged defines the callback to call when value changes
  76251. * @returns a StackPanel containing the radio button and a textBlock
  76252. */
  76253. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76254. }
  76255. }
  76256. declare module BABYLON.GUI {
  76257. /**
  76258. * Class used to create slider controls
  76259. */
  76260. export class BaseSlider extends Control {
  76261. name?: string | undefined;
  76262. protected _thumbWidth: ValueAndUnit;
  76263. private _minimum;
  76264. private _maximum;
  76265. private _value;
  76266. private _isVertical;
  76267. protected _barOffset: ValueAndUnit;
  76268. private _isThumbClamped;
  76269. protected _displayThumb: boolean;
  76270. private _step;
  76271. private _lastPointerDownID;
  76272. protected _effectiveBarOffset: number;
  76273. protected _renderLeft: number;
  76274. protected _renderTop: number;
  76275. protected _renderWidth: number;
  76276. protected _renderHeight: number;
  76277. protected _backgroundBoxLength: number;
  76278. protected _backgroundBoxThickness: number;
  76279. protected _effectiveThumbThickness: number;
  76280. /** BABYLON.Observable raised when the sldier value changes */
  76281. onValueChangedObservable: BABYLON.Observable<number>;
  76282. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76283. get displayThumb(): boolean;
  76284. set displayThumb(value: boolean);
  76285. /** Gets or sets a step to apply to values (0 by default) */
  76286. get step(): number;
  76287. set step(value: number);
  76288. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76289. get barOffset(): string | number;
  76290. /** Gets main bar offset in pixels*/
  76291. get barOffsetInPixels(): number;
  76292. set barOffset(value: string | number);
  76293. /** Gets or sets thumb width */
  76294. get thumbWidth(): string | number;
  76295. /** Gets thumb width in pixels */
  76296. get thumbWidthInPixels(): number;
  76297. set thumbWidth(value: string | number);
  76298. /** Gets or sets minimum value */
  76299. get minimum(): number;
  76300. set minimum(value: number);
  76301. /** Gets or sets maximum value */
  76302. get maximum(): number;
  76303. set maximum(value: number);
  76304. /** Gets or sets current value */
  76305. get value(): number;
  76306. set value(value: number);
  76307. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76308. get isVertical(): boolean;
  76309. set isVertical(value: boolean);
  76310. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76311. get isThumbClamped(): boolean;
  76312. set isThumbClamped(value: boolean);
  76313. /**
  76314. * Creates a new BaseSlider
  76315. * @param name defines the control name
  76316. */
  76317. constructor(name?: string | undefined);
  76318. protected _getTypeName(): string;
  76319. protected _getThumbPosition(): number;
  76320. protected _getThumbThickness(type: string): number;
  76321. protected _prepareRenderingData(type: string): void;
  76322. private _pointerIsDown;
  76323. /** @hidden */
  76324. protected _updateValueFromPointer(x: number, y: number): void;
  76325. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76326. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76327. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76328. }
  76329. }
  76330. declare module BABYLON.GUI {
  76331. /**
  76332. * Class used to create slider controls
  76333. */
  76334. export class Slider extends BaseSlider {
  76335. name?: string | undefined;
  76336. private _background;
  76337. private _borderColor;
  76338. private _isThumbCircle;
  76339. protected _displayValueBar: boolean;
  76340. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76341. get displayValueBar(): boolean;
  76342. set displayValueBar(value: boolean);
  76343. /** Gets or sets border color */
  76344. get borderColor(): string;
  76345. set borderColor(value: string);
  76346. /** Gets or sets background color */
  76347. get background(): string;
  76348. set background(value: string);
  76349. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76350. get isThumbCircle(): boolean;
  76351. set isThumbCircle(value: boolean);
  76352. /**
  76353. * Creates a new Slider
  76354. * @param name defines the control name
  76355. */
  76356. constructor(name?: string | undefined);
  76357. protected _getTypeName(): string;
  76358. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76359. }
  76360. }
  76361. declare module BABYLON.GUI {
  76362. /** Class used to create a RadioGroup
  76363. * which contains groups of radio buttons
  76364. */
  76365. export class SelectorGroup {
  76366. /** name of SelectorGroup */
  76367. name: string;
  76368. private _groupPanel;
  76369. private _selectors;
  76370. private _groupHeader;
  76371. /**
  76372. * Creates a new SelectorGroup
  76373. * @param name of group, used as a group heading
  76374. */
  76375. constructor(
  76376. /** name of SelectorGroup */
  76377. name: string);
  76378. /** Gets the groupPanel of the SelectorGroup */
  76379. get groupPanel(): StackPanel;
  76380. /** Gets the selectors array */
  76381. get selectors(): StackPanel[];
  76382. /** Gets and sets the group header */
  76383. get header(): string;
  76384. set header(label: string);
  76385. /** @hidden */
  76386. private _addGroupHeader;
  76387. /** @hidden*/
  76388. _getSelector(selectorNb: number): StackPanel | undefined;
  76389. /** Removes the selector at the given position
  76390. * @param selectorNb the position of the selector within the group
  76391. */
  76392. removeSelector(selectorNb: number): void;
  76393. }
  76394. /** Class used to create a CheckboxGroup
  76395. * which contains groups of checkbox buttons
  76396. */
  76397. export class CheckboxGroup extends SelectorGroup {
  76398. /** Adds a checkbox as a control
  76399. * @param text is the label for the selector
  76400. * @param func is the function called when the Selector is checked
  76401. * @param checked is true when Selector is checked
  76402. */
  76403. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76404. /** @hidden */
  76405. _setSelectorLabel(selectorNb: number, label: string): void;
  76406. /** @hidden */
  76407. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76408. /** @hidden */
  76409. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76410. /** @hidden */
  76411. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76412. }
  76413. /** Class used to create a RadioGroup
  76414. * which contains groups of radio buttons
  76415. */
  76416. export class RadioGroup extends SelectorGroup {
  76417. private _selectNb;
  76418. /** Adds a radio button as a control
  76419. * @param label is the label for the selector
  76420. * @param func is the function called when the Selector is checked
  76421. * @param checked is true when Selector is checked
  76422. */
  76423. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76424. /** @hidden */
  76425. _setSelectorLabel(selectorNb: number, label: string): void;
  76426. /** @hidden */
  76427. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76428. /** @hidden */
  76429. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76430. /** @hidden */
  76431. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76432. }
  76433. /** Class used to create a SliderGroup
  76434. * which contains groups of slider buttons
  76435. */
  76436. export class SliderGroup extends SelectorGroup {
  76437. /**
  76438. * Adds a slider to the SelectorGroup
  76439. * @param label is the label for the SliderBar
  76440. * @param func is the function called when the Slider moves
  76441. * @param unit is a string describing the units used, eg degrees or metres
  76442. * @param min is the minimum value for the Slider
  76443. * @param max is the maximum value for the Slider
  76444. * @param value is the start value for the Slider between min and max
  76445. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76446. */
  76447. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76448. /** @hidden */
  76449. _setSelectorLabel(selectorNb: number, label: string): void;
  76450. /** @hidden */
  76451. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76452. /** @hidden */
  76453. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76454. /** @hidden */
  76455. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76456. }
  76457. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76458. * @see http://doc.babylonjs.com/how_to/selector
  76459. */
  76460. export class SelectionPanel extends Rectangle {
  76461. /** name of SelectionPanel */
  76462. name: string;
  76463. /** an array of SelectionGroups */
  76464. groups: SelectorGroup[];
  76465. private _panel;
  76466. private _buttonColor;
  76467. private _buttonBackground;
  76468. private _headerColor;
  76469. private _barColor;
  76470. private _barHeight;
  76471. private _spacerHeight;
  76472. private _labelColor;
  76473. private _groups;
  76474. private _bars;
  76475. /**
  76476. * Creates a new SelectionPanel
  76477. * @param name of SelectionPanel
  76478. * @param groups is an array of SelectionGroups
  76479. */
  76480. constructor(
  76481. /** name of SelectionPanel */
  76482. name: string,
  76483. /** an array of SelectionGroups */
  76484. groups?: SelectorGroup[]);
  76485. protected _getTypeName(): string;
  76486. /** Gets or sets the headerColor */
  76487. get headerColor(): string;
  76488. set headerColor(color: string);
  76489. private _setHeaderColor;
  76490. /** Gets or sets the button color */
  76491. get buttonColor(): string;
  76492. set buttonColor(color: string);
  76493. private _setbuttonColor;
  76494. /** Gets or sets the label color */
  76495. get labelColor(): string;
  76496. set labelColor(color: string);
  76497. private _setLabelColor;
  76498. /** Gets or sets the button background */
  76499. get buttonBackground(): string;
  76500. set buttonBackground(color: string);
  76501. private _setButtonBackground;
  76502. /** Gets or sets the color of separator bar */
  76503. get barColor(): string;
  76504. set barColor(color: string);
  76505. private _setBarColor;
  76506. /** Gets or sets the height of separator bar */
  76507. get barHeight(): string;
  76508. set barHeight(value: string);
  76509. private _setBarHeight;
  76510. /** Gets or sets the height of spacers*/
  76511. get spacerHeight(): string;
  76512. set spacerHeight(value: string);
  76513. private _setSpacerHeight;
  76514. /** Adds a bar between groups */
  76515. private _addSpacer;
  76516. /** Add a group to the selection panel
  76517. * @param group is the selector group to add
  76518. */
  76519. addGroup(group: SelectorGroup): void;
  76520. /** Remove the group from the given position
  76521. * @param groupNb is the position of the group in the list
  76522. */
  76523. removeGroup(groupNb: number): void;
  76524. /** Change a group header label
  76525. * @param label is the new group header label
  76526. * @param groupNb is the number of the group to relabel
  76527. * */
  76528. setHeaderName(label: string, groupNb: number): void;
  76529. /** Change selector label to the one given
  76530. * @param label is the new selector label
  76531. * @param groupNb is the number of the groupcontaining the selector
  76532. * @param selectorNb is the number of the selector within a group to relabel
  76533. * */
  76534. relabel(label: string, groupNb: number, selectorNb: number): void;
  76535. /** For a given group position remove the selector at the given position
  76536. * @param groupNb is the number of the group to remove the selector from
  76537. * @param selectorNb is the number of the selector within the group
  76538. */
  76539. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  76540. /** For a given group position of correct type add a checkbox button
  76541. * @param groupNb is the number of the group to remove the selector from
  76542. * @param label is the label for the selector
  76543. * @param func is the function called when the Selector is checked
  76544. * @param checked is true when Selector is checked
  76545. */
  76546. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76547. /** For a given group position of correct type add a radio button
  76548. * @param groupNb is the number of the group to remove the selector from
  76549. * @param label is the label for the selector
  76550. * @param func is the function called when the Selector is checked
  76551. * @param checked is true when Selector is checked
  76552. */
  76553. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  76554. /**
  76555. * For a given slider group add a slider
  76556. * @param groupNb is the number of the group to add the slider to
  76557. * @param label is the label for the Slider
  76558. * @param func is the function called when the Slider moves
  76559. * @param unit is a string describing the units used, eg degrees or metres
  76560. * @param min is the minimum value for the Slider
  76561. * @param max is the maximum value for the Slider
  76562. * @param value is the start value for the Slider between min and max
  76563. * @param onVal is the function used to format the value displayed, eg radians to degrees
  76564. */
  76565. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  76566. }
  76567. }
  76568. declare module BABYLON.GUI {
  76569. /**
  76570. * Class used to hold a the container for ScrollViewer
  76571. * @hidden
  76572. */
  76573. export class _ScrollViewerWindow extends Container {
  76574. parentClientWidth: number;
  76575. parentClientHeight: number;
  76576. private _freezeControls;
  76577. private _parentMeasure;
  76578. private _oldLeft;
  76579. private _oldTop;
  76580. get freezeControls(): boolean;
  76581. set freezeControls(value: boolean);
  76582. private _bucketWidth;
  76583. private _bucketHeight;
  76584. private _buckets;
  76585. private _bucketLen;
  76586. get bucketWidth(): number;
  76587. get bucketHeight(): number;
  76588. setBucketSizes(width: number, height: number): void;
  76589. private _useBuckets;
  76590. private _makeBuckets;
  76591. private _dispatchInBuckets;
  76592. private _updateMeasures;
  76593. private _updateChildrenMeasures;
  76594. private _restoreMeasures;
  76595. /**
  76596. * Creates a new ScrollViewerWindow
  76597. * @param name of ScrollViewerWindow
  76598. */
  76599. constructor(name?: string);
  76600. protected _getTypeName(): string;
  76601. /** @hidden */
  76602. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76603. /** @hidden */
  76604. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76605. private _scrollChildren;
  76606. private _scrollChildrenWithBuckets;
  76607. /** @hidden */
  76608. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76609. protected _postMeasure(): void;
  76610. }
  76611. }
  76612. declare module BABYLON.GUI {
  76613. /**
  76614. * Class used to create slider controls
  76615. */
  76616. export class ScrollBar extends BaseSlider {
  76617. name?: string | undefined;
  76618. private _background;
  76619. private _borderColor;
  76620. private _tempMeasure;
  76621. /** Gets or sets border color */
  76622. get borderColor(): string;
  76623. set borderColor(value: string);
  76624. /** Gets or sets background color */
  76625. get background(): string;
  76626. set background(value: string);
  76627. /**
  76628. * Creates a new Slider
  76629. * @param name defines the control name
  76630. */
  76631. constructor(name?: string | undefined);
  76632. protected _getTypeName(): string;
  76633. protected _getThumbThickness(): number;
  76634. _draw(context: CanvasRenderingContext2D): void;
  76635. private _first;
  76636. private _originX;
  76637. private _originY;
  76638. /** @hidden */
  76639. protected _updateValueFromPointer(x: number, y: number): void;
  76640. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76641. }
  76642. }
  76643. declare module BABYLON.GUI {
  76644. /**
  76645. * Class used to create slider controls
  76646. */
  76647. export class ImageScrollBar extends BaseSlider {
  76648. name?: string | undefined;
  76649. private _backgroundBaseImage;
  76650. private _backgroundImage;
  76651. private _thumbImage;
  76652. private _thumbBaseImage;
  76653. private _thumbLength;
  76654. private _thumbHeight;
  76655. private _barImageHeight;
  76656. private _tempMeasure;
  76657. /** Number of 90° rotation to apply on the images when in vertical mode */
  76658. num90RotationInVerticalMode: number;
  76659. /**
  76660. * Gets or sets the image used to render the background for horizontal bar
  76661. */
  76662. get backgroundImage(): Image;
  76663. set backgroundImage(value: Image);
  76664. /**
  76665. * Gets or sets the image used to render the thumb
  76666. */
  76667. get thumbImage(): Image;
  76668. set thumbImage(value: Image);
  76669. /**
  76670. * Gets or sets the length of the thumb
  76671. */
  76672. get thumbLength(): number;
  76673. set thumbLength(value: number);
  76674. /**
  76675. * Gets or sets the height of the thumb
  76676. */
  76677. get thumbHeight(): number;
  76678. set thumbHeight(value: number);
  76679. /**
  76680. * Gets or sets the height of the bar image
  76681. */
  76682. get barImageHeight(): number;
  76683. set barImageHeight(value: number);
  76684. /**
  76685. * Creates a new ImageScrollBar
  76686. * @param name defines the control name
  76687. */
  76688. constructor(name?: string | undefined);
  76689. protected _getTypeName(): string;
  76690. protected _getThumbThickness(): number;
  76691. _draw(context: CanvasRenderingContext2D): void;
  76692. private _first;
  76693. private _originX;
  76694. private _originY;
  76695. /** @hidden */
  76696. protected _updateValueFromPointer(x: number, y: number): void;
  76697. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76698. }
  76699. }
  76700. declare module BABYLON.GUI {
  76701. /**
  76702. * Class used to hold a viewer window and sliders in a grid
  76703. */
  76704. export class ScrollViewer extends Rectangle {
  76705. private _grid;
  76706. private _horizontalBarSpace;
  76707. private _verticalBarSpace;
  76708. private _dragSpace;
  76709. private _horizontalBar;
  76710. private _verticalBar;
  76711. private _barColor;
  76712. private _barBackground;
  76713. private _barImage;
  76714. private _horizontalBarImage;
  76715. private _verticalBarImage;
  76716. private _barBackgroundImage;
  76717. private _horizontalBarBackgroundImage;
  76718. private _verticalBarBackgroundImage;
  76719. private _barSize;
  76720. private _window;
  76721. private _pointerIsOver;
  76722. private _wheelPrecision;
  76723. private _onWheelObserver;
  76724. private _clientWidth;
  76725. private _clientHeight;
  76726. private _useImageBar;
  76727. private _thumbLength;
  76728. private _thumbHeight;
  76729. private _barImageHeight;
  76730. private _horizontalBarImageHeight;
  76731. private _verticalBarImageHeight;
  76732. private _oldWindowContentsWidth;
  76733. private _oldWindowContentsHeight;
  76734. /**
  76735. * Gets the horizontal scrollbar
  76736. */
  76737. get horizontalBar(): ScrollBar | ImageScrollBar;
  76738. /**
  76739. * Gets the vertical scrollbar
  76740. */
  76741. get verticalBar(): ScrollBar | ImageScrollBar;
  76742. /**
  76743. * Adds a new control to the current container
  76744. * @param control defines the control to add
  76745. * @returns the current container
  76746. */
  76747. addControl(control: BABYLON.Nullable<Control>): Container;
  76748. /**
  76749. * Removes a control from the current container
  76750. * @param control defines the control to remove
  76751. * @returns the current container
  76752. */
  76753. removeControl(control: Control): Container;
  76754. /** Gets the list of children */
  76755. get children(): Control[];
  76756. _flagDescendantsAsMatrixDirty(): void;
  76757. /**
  76758. * Freezes or unfreezes the controls in the window.
  76759. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  76760. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  76761. */
  76762. get freezeControls(): boolean;
  76763. set freezeControls(value: boolean);
  76764. /** Gets the bucket width */
  76765. get bucketWidth(): number;
  76766. /** Gets the bucket height */
  76767. get bucketHeight(): number;
  76768. /**
  76769. * Sets the bucket sizes.
  76770. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  76771. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  76772. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  76773. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  76774. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  76775. * used), that's why it is not enabled by default.
  76776. * @param width width of the bucket
  76777. * @param height height of the bucket
  76778. */
  76779. setBucketSizes(width: number, height: number): void;
  76780. private _forceHorizontalBar;
  76781. private _forceVerticalBar;
  76782. /**
  76783. * Forces the horizontal scroll bar to be displayed
  76784. */
  76785. get forceHorizontalBar(): boolean;
  76786. set forceHorizontalBar(value: boolean);
  76787. /**
  76788. * Forces the vertical scroll bar to be displayed
  76789. */
  76790. get forceVerticalBar(): boolean;
  76791. set forceVerticalBar(value: boolean);
  76792. /**
  76793. * Creates a new ScrollViewer
  76794. * @param name of ScrollViewer
  76795. */
  76796. constructor(name?: string, isImageBased?: boolean);
  76797. /** Reset the scroll viewer window to initial size */
  76798. resetWindow(): void;
  76799. protected _getTypeName(): string;
  76800. private _buildClientSizes;
  76801. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76802. protected _postMeasure(): void;
  76803. /**
  76804. * Gets or sets the mouse wheel precision
  76805. * from 0 to 1 with a default value of 0.05
  76806. * */
  76807. get wheelPrecision(): number;
  76808. set wheelPrecision(value: number);
  76809. /** Gets or sets the scroll bar container background color */
  76810. get scrollBackground(): string;
  76811. set scrollBackground(color: string);
  76812. /** Gets or sets the bar color */
  76813. get barColor(): string;
  76814. set barColor(color: string);
  76815. /** Gets or sets the bar image */
  76816. get thumbImage(): Image;
  76817. set thumbImage(value: Image);
  76818. /** Gets or sets the horizontal bar image */
  76819. get horizontalThumbImage(): Image;
  76820. set horizontalThumbImage(value: Image);
  76821. /** Gets or sets the vertical bar image */
  76822. get verticalThumbImage(): Image;
  76823. set verticalThumbImage(value: Image);
  76824. /** Gets or sets the size of the bar */
  76825. get barSize(): number;
  76826. set barSize(value: number);
  76827. /** Gets or sets the length of the thumb */
  76828. get thumbLength(): number;
  76829. set thumbLength(value: number);
  76830. /** Gets or sets the height of the thumb */
  76831. get thumbHeight(): number;
  76832. set thumbHeight(value: number);
  76833. /** Gets or sets the height of the bar image */
  76834. get barImageHeight(): number;
  76835. set barImageHeight(value: number);
  76836. /** Gets or sets the height of the horizontal bar image */
  76837. get horizontalBarImageHeight(): number;
  76838. set horizontalBarImageHeight(value: number);
  76839. /** Gets or sets the height of the vertical bar image */
  76840. get verticalBarImageHeight(): number;
  76841. set verticalBarImageHeight(value: number);
  76842. /** Gets or sets the bar background */
  76843. get barBackground(): string;
  76844. set barBackground(color: string);
  76845. /** Gets or sets the bar background image */
  76846. get barImage(): Image;
  76847. set barImage(value: Image);
  76848. /** Gets or sets the horizontal bar background image */
  76849. get horizontalBarImage(): Image;
  76850. set horizontalBarImage(value: Image);
  76851. /** Gets or sets the vertical bar background image */
  76852. get verticalBarImage(): Image;
  76853. set verticalBarImage(value: Image);
  76854. private _setWindowPosition;
  76855. /** @hidden */
  76856. private _updateScroller;
  76857. _link(host: AdvancedDynamicTexture): void;
  76858. /** @hidden */
  76859. private _addBar;
  76860. /** @hidden */
  76861. private _attachWheel;
  76862. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76863. /** Releases associated resources */
  76864. dispose(): void;
  76865. }
  76866. }
  76867. declare module BABYLON.GUI {
  76868. /** Class used to render a grid */
  76869. export class DisplayGrid extends Control {
  76870. name?: string | undefined;
  76871. private _cellWidth;
  76872. private _cellHeight;
  76873. private _minorLineTickness;
  76874. private _minorLineColor;
  76875. private _majorLineTickness;
  76876. private _majorLineColor;
  76877. private _majorLineFrequency;
  76878. private _background;
  76879. private _displayMajorLines;
  76880. private _displayMinorLines;
  76881. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  76882. get displayMinorLines(): boolean;
  76883. set displayMinorLines(value: boolean);
  76884. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  76885. get displayMajorLines(): boolean;
  76886. set displayMajorLines(value: boolean);
  76887. /** Gets or sets background color (Black by default) */
  76888. get background(): string;
  76889. set background(value: string);
  76890. /** Gets or sets the width of each cell (20 by default) */
  76891. get cellWidth(): number;
  76892. set cellWidth(value: number);
  76893. /** Gets or sets the height of each cell (20 by default) */
  76894. get cellHeight(): number;
  76895. set cellHeight(value: number);
  76896. /** Gets or sets the tickness of minor lines (1 by default) */
  76897. get minorLineTickness(): number;
  76898. set minorLineTickness(value: number);
  76899. /** Gets or sets the color of minor lines (DarkGray by default) */
  76900. get minorLineColor(): string;
  76901. set minorLineColor(value: string);
  76902. /** Gets or sets the tickness of major lines (2 by default) */
  76903. get majorLineTickness(): number;
  76904. set majorLineTickness(value: number);
  76905. /** Gets or sets the color of major lines (White by default) */
  76906. get majorLineColor(): string;
  76907. set majorLineColor(value: string);
  76908. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  76909. get majorLineFrequency(): number;
  76910. set majorLineFrequency(value: number);
  76911. /**
  76912. * Creates a new GridDisplayRectangle
  76913. * @param name defines the control name
  76914. */
  76915. constructor(name?: string | undefined);
  76916. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76917. protected _getTypeName(): string;
  76918. }
  76919. }
  76920. declare module BABYLON.GUI {
  76921. /**
  76922. * Class used to create slider controls based on images
  76923. */
  76924. export class ImageBasedSlider extends BaseSlider {
  76925. name?: string | undefined;
  76926. private _backgroundImage;
  76927. private _thumbImage;
  76928. private _valueBarImage;
  76929. private _tempMeasure;
  76930. get displayThumb(): boolean;
  76931. set displayThumb(value: boolean);
  76932. /**
  76933. * Gets or sets the image used to render the background
  76934. */
  76935. get backgroundImage(): Image;
  76936. set backgroundImage(value: Image);
  76937. /**
  76938. * Gets or sets the image used to render the value bar
  76939. */
  76940. get valueBarImage(): Image;
  76941. set valueBarImage(value: Image);
  76942. /**
  76943. * Gets or sets the image used to render the thumb
  76944. */
  76945. get thumbImage(): Image;
  76946. set thumbImage(value: Image);
  76947. /**
  76948. * Creates a new ImageBasedSlider
  76949. * @param name defines the control name
  76950. */
  76951. constructor(name?: string | undefined);
  76952. protected _getTypeName(): string;
  76953. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76954. }
  76955. }
  76956. declare module BABYLON.GUI {
  76957. /**
  76958. * Forcing an export so that this code will execute
  76959. * @hidden
  76960. */
  76961. const name = "Statics";
  76962. }
  76963. declare module BABYLON.GUI {
  76964. /**
  76965. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  76966. */
  76967. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  76968. /**
  76969. * Define the instrumented AdvancedDynamicTexture.
  76970. */
  76971. texture: AdvancedDynamicTexture;
  76972. private _captureRenderTime;
  76973. private _renderTime;
  76974. private _captureLayoutTime;
  76975. private _layoutTime;
  76976. private _onBeginRenderObserver;
  76977. private _onEndRenderObserver;
  76978. private _onBeginLayoutObserver;
  76979. private _onEndLayoutObserver;
  76980. /**
  76981. * Gets the perf counter used to capture render time
  76982. */
  76983. get renderTimeCounter(): BABYLON.PerfCounter;
  76984. /**
  76985. * Gets the perf counter used to capture layout time
  76986. */
  76987. get layoutTimeCounter(): BABYLON.PerfCounter;
  76988. /**
  76989. * Enable or disable the render time capture
  76990. */
  76991. get captureRenderTime(): boolean;
  76992. set captureRenderTime(value: boolean);
  76993. /**
  76994. * Enable or disable the layout time capture
  76995. */
  76996. get captureLayoutTime(): boolean;
  76997. set captureLayoutTime(value: boolean);
  76998. /**
  76999. * Instantiates a new advanced dynamic texture instrumentation.
  77000. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77001. * @param texture Defines the AdvancedDynamicTexture to instrument
  77002. */
  77003. constructor(
  77004. /**
  77005. * Define the instrumented AdvancedDynamicTexture.
  77006. */
  77007. texture: AdvancedDynamicTexture);
  77008. /**
  77009. * Dispose and release associated resources.
  77010. */
  77011. dispose(): void;
  77012. }
  77013. }
  77014. declare module BABYLON.GUI {
  77015. /**
  77016. * Class used to load GUI via XML.
  77017. */
  77018. export class XmlLoader {
  77019. private _nodes;
  77020. private _nodeTypes;
  77021. private _isLoaded;
  77022. private _objectAttributes;
  77023. private _parentClass;
  77024. /**
  77025. * Create a new xml loader
  77026. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  77027. */
  77028. constructor(parentClass?: null);
  77029. private _getChainElement;
  77030. private _getClassAttribute;
  77031. private _createGuiElement;
  77032. private _parseGrid;
  77033. private _parseElement;
  77034. private _prepareSourceElement;
  77035. private _parseElementsFromSource;
  77036. private _parseXml;
  77037. /**
  77038. * Gets if the loading has finished.
  77039. * @returns whether the loading has finished or not
  77040. */
  77041. isLoaded(): boolean;
  77042. /**
  77043. * Gets a loaded node / control by id.
  77044. * @param id the Controls id set in the xml
  77045. * @returns element of type Control
  77046. */
  77047. getNodeById(id: string): any;
  77048. /**
  77049. * Gets all loaded nodes / controls
  77050. * @returns Array of controls
  77051. */
  77052. getNodes(): any;
  77053. /**
  77054. * Initiates the xml layout loading
  77055. * @param xmlFile defines the xml layout to load
  77056. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  77057. * @param callback defines the callback called on layout load.
  77058. */
  77059. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  77060. }
  77061. }
  77062. declare module BABYLON.GUI {
  77063. /**
  77064. * Class used to create containers for controls
  77065. */
  77066. export class Container3D extends Control3D {
  77067. private _blockLayout;
  77068. /**
  77069. * Gets the list of child controls
  77070. */
  77071. protected _children: Control3D[];
  77072. /**
  77073. * Gets the list of child controls
  77074. */
  77075. get children(): Array<Control3D>;
  77076. /**
  77077. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  77078. * This is helpful to optimize layout operation when adding multiple children in a row
  77079. */
  77080. get blockLayout(): boolean;
  77081. set blockLayout(value: boolean);
  77082. /**
  77083. * Creates a new container
  77084. * @param name defines the container name
  77085. */
  77086. constructor(name?: string);
  77087. /**
  77088. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  77089. * @returns the current container
  77090. */
  77091. updateLayout(): Container3D;
  77092. /**
  77093. * Gets a boolean indicating if the given control is in the children of this control
  77094. * @param control defines the control to check
  77095. * @returns true if the control is in the child list
  77096. */
  77097. containsControl(control: Control3D): boolean;
  77098. /**
  77099. * Adds a control to the children of this control
  77100. * @param control defines the control to add
  77101. * @returns the current container
  77102. */
  77103. addControl(control: Control3D): Container3D;
  77104. /**
  77105. * This function will be called everytime a new control is added
  77106. */
  77107. protected _arrangeChildren(): void;
  77108. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77109. /**
  77110. * Removes a control from the children of this control
  77111. * @param control defines the control to remove
  77112. * @returns the current container
  77113. */
  77114. removeControl(control: Control3D): Container3D;
  77115. protected _getTypeName(): string;
  77116. /**
  77117. * Releases all associated resources
  77118. */
  77119. dispose(): void;
  77120. /** Control rotation will remain unchanged */
  77121. static readonly UNSET_ORIENTATION: number;
  77122. /** Control will rotate to make it look at sphere central axis */
  77123. static readonly FACEORIGIN_ORIENTATION: number;
  77124. /** Control will rotate to make it look back at sphere central axis */
  77125. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  77126. /** Control will rotate to look at z axis (0, 0, 1) */
  77127. static readonly FACEFORWARD_ORIENTATION: number;
  77128. /** Control will rotate to look at negative z axis (0, 0, -1) */
  77129. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  77130. }
  77131. }
  77132. declare module BABYLON.GUI {
  77133. /**
  77134. * Class used to manage 3D user interface
  77135. * @see http://doc.babylonjs.com/how_to/gui3d
  77136. */
  77137. export class GUI3DManager implements BABYLON.IDisposable {
  77138. private _scene;
  77139. private _sceneDisposeObserver;
  77140. private _utilityLayer;
  77141. private _rootContainer;
  77142. private _pointerObserver;
  77143. private _pointerOutObserver;
  77144. /** @hidden */
  77145. _lastPickedControl: Control3D;
  77146. /** @hidden */
  77147. _lastControlOver: {
  77148. [pointerId: number]: Control3D;
  77149. };
  77150. /** @hidden */
  77151. _lastControlDown: {
  77152. [pointerId: number]: Control3D;
  77153. };
  77154. /**
  77155. * BABYLON.Observable raised when the point picked by the pointer events changed
  77156. */
  77157. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77158. /** @hidden */
  77159. _sharedMaterials: {
  77160. [key: string]: BABYLON.Material;
  77161. };
  77162. /** Gets the hosting scene */
  77163. get scene(): BABYLON.Scene;
  77164. /** Gets associated utility layer */
  77165. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77166. /**
  77167. * Creates a new GUI3DManager
  77168. * @param scene
  77169. */
  77170. constructor(scene?: BABYLON.Scene);
  77171. private _handlePointerOut;
  77172. private _doPicking;
  77173. /**
  77174. * Gets the root container
  77175. */
  77176. get rootContainer(): Container3D;
  77177. /**
  77178. * Gets a boolean indicating if the given control is in the root child list
  77179. * @param control defines the control to check
  77180. * @returns true if the control is in the root child list
  77181. */
  77182. containsControl(control: Control3D): boolean;
  77183. /**
  77184. * Adds a control to the root child list
  77185. * @param control defines the control to add
  77186. * @returns the current manager
  77187. */
  77188. addControl(control: Control3D): GUI3DManager;
  77189. /**
  77190. * Removes a control from the root child list
  77191. * @param control defines the control to remove
  77192. * @returns the current container
  77193. */
  77194. removeControl(control: Control3D): GUI3DManager;
  77195. /**
  77196. * Releases all associated resources
  77197. */
  77198. dispose(): void;
  77199. }
  77200. }
  77201. declare module BABYLON.GUI {
  77202. /**
  77203. * Class used to transport BABYLON.Vector3 information for pointer events
  77204. */
  77205. export class Vector3WithInfo extends BABYLON.Vector3 {
  77206. /** defines the current mouse button index */
  77207. buttonIndex: number;
  77208. /**
  77209. * Creates a new Vector3WithInfo
  77210. * @param source defines the vector3 data to transport
  77211. * @param buttonIndex defines the current mouse button index
  77212. */
  77213. constructor(source: BABYLON.Vector3,
  77214. /** defines the current mouse button index */
  77215. buttonIndex?: number);
  77216. }
  77217. }
  77218. declare module BABYLON.GUI {
  77219. /**
  77220. * Class used as base class for controls
  77221. */
  77222. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77223. /** Defines the control name */
  77224. name?: string | undefined;
  77225. /** @hidden */
  77226. _host: GUI3DManager;
  77227. private _node;
  77228. private _downCount;
  77229. private _enterCount;
  77230. private _downPointerIds;
  77231. private _isVisible;
  77232. /** Gets or sets the control position in world space */
  77233. get position(): BABYLON.Vector3;
  77234. set position(value: BABYLON.Vector3);
  77235. /** Gets or sets the control scaling in world space */
  77236. get scaling(): BABYLON.Vector3;
  77237. set scaling(value: BABYLON.Vector3);
  77238. /** Callback used to start pointer enter animation */
  77239. pointerEnterAnimation: () => void;
  77240. /** Callback used to start pointer out animation */
  77241. pointerOutAnimation: () => void;
  77242. /** Callback used to start pointer down animation */
  77243. pointerDownAnimation: () => void;
  77244. /** Callback used to start pointer up animation */
  77245. pointerUpAnimation: () => void;
  77246. /**
  77247. * An event triggered when the pointer move over the control
  77248. */
  77249. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77250. /**
  77251. * An event triggered when the pointer move out of the control
  77252. */
  77253. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77254. /**
  77255. * An event triggered when the pointer taps the control
  77256. */
  77257. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77258. /**
  77259. * An event triggered when pointer is up
  77260. */
  77261. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77262. /**
  77263. * An event triggered when a control is clicked on (with a mouse)
  77264. */
  77265. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77266. /**
  77267. * An event triggered when pointer enters the control
  77268. */
  77269. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77270. /**
  77271. * Gets or sets the parent container
  77272. */
  77273. parent: BABYLON.Nullable<Container3D>;
  77274. private _behaviors;
  77275. /**
  77276. * Gets the list of attached behaviors
  77277. * @see http://doc.babylonjs.com/features/behaviour
  77278. */
  77279. get behaviors(): BABYLON.Behavior<Control3D>[];
  77280. /**
  77281. * Attach a behavior to the control
  77282. * @see http://doc.babylonjs.com/features/behaviour
  77283. * @param behavior defines the behavior to attach
  77284. * @returns the current control
  77285. */
  77286. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77287. /**
  77288. * Remove an attached behavior
  77289. * @see http://doc.babylonjs.com/features/behaviour
  77290. * @param behavior defines the behavior to attach
  77291. * @returns the current control
  77292. */
  77293. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77294. /**
  77295. * Gets an attached behavior by name
  77296. * @param name defines the name of the behavior to look for
  77297. * @see http://doc.babylonjs.com/features/behaviour
  77298. * @returns null if behavior was not found else the requested behavior
  77299. */
  77300. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77301. /** Gets or sets a boolean indicating if the control is visible */
  77302. get isVisible(): boolean;
  77303. set isVisible(value: boolean);
  77304. /**
  77305. * Creates a new control
  77306. * @param name defines the control name
  77307. */
  77308. constructor(
  77309. /** Defines the control name */
  77310. name?: string | undefined);
  77311. /**
  77312. * Gets a string representing the class name
  77313. */
  77314. get typeName(): string;
  77315. /**
  77316. * Get the current class name of the control.
  77317. * @returns current class name
  77318. */
  77319. getClassName(): string;
  77320. protected _getTypeName(): string;
  77321. /**
  77322. * Gets the transform node used by this control
  77323. */
  77324. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77325. /**
  77326. * Gets the mesh used to render this control
  77327. */
  77328. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77329. /**
  77330. * Link the control as child of the given node
  77331. * @param node defines the node to link to. Use null to unlink the control
  77332. * @returns the current control
  77333. */
  77334. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77335. /** @hidden **/
  77336. _prepareNode(scene: BABYLON.Scene): void;
  77337. /**
  77338. * Node creation.
  77339. * Can be overriden by children
  77340. * @param scene defines the scene where the node must be attached
  77341. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77342. */
  77343. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77344. /**
  77345. * Affect a material to the given mesh
  77346. * @param mesh defines the mesh which will represent the control
  77347. */
  77348. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77349. /** @hidden */
  77350. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77351. /** @hidden */
  77352. _onPointerEnter(target: Control3D): boolean;
  77353. /** @hidden */
  77354. _onPointerOut(target: Control3D): void;
  77355. /** @hidden */
  77356. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77357. /** @hidden */
  77358. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77359. /** @hidden */
  77360. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77361. /** @hidden */
  77362. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77363. /** @hidden */
  77364. _disposeNode(): void;
  77365. /**
  77366. * Releases all associated resources
  77367. */
  77368. dispose(): void;
  77369. }
  77370. }
  77371. declare module BABYLON.GUI {
  77372. /**
  77373. * Class used as a root to all buttons
  77374. */
  77375. export class AbstractButton3D extends Control3D {
  77376. /**
  77377. * Creates a new button
  77378. * @param name defines the control name
  77379. */
  77380. constructor(name?: string);
  77381. protected _getTypeName(): string;
  77382. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77383. }
  77384. }
  77385. declare module BABYLON.GUI {
  77386. /**
  77387. * Class used to create a button in 3D
  77388. */
  77389. export class Button3D extends AbstractButton3D {
  77390. /** @hidden */
  77391. protected _currentMaterial: BABYLON.Material;
  77392. private _facadeTexture;
  77393. private _content;
  77394. private _contentResolution;
  77395. private _contentScaleRatio;
  77396. /**
  77397. * Gets or sets the texture resolution used to render content (512 by default)
  77398. */
  77399. get contentResolution(): BABYLON.int;
  77400. set contentResolution(value: BABYLON.int);
  77401. /**
  77402. * Gets or sets the texture scale ratio used to render content (2 by default)
  77403. */
  77404. get contentScaleRatio(): number;
  77405. set contentScaleRatio(value: number);
  77406. protected _disposeFacadeTexture(): void;
  77407. protected _resetContent(): void;
  77408. /**
  77409. * Creates a new button
  77410. * @param name defines the control name
  77411. */
  77412. constructor(name?: string);
  77413. /**
  77414. * Gets or sets the GUI 2D content used to display the button's facade
  77415. */
  77416. get content(): Control;
  77417. set content(value: Control);
  77418. /**
  77419. * Apply the facade texture (created from the content property).
  77420. * This function can be overloaded by child classes
  77421. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77422. */
  77423. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77424. protected _getTypeName(): string;
  77425. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77426. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77427. /**
  77428. * Releases all associated resources
  77429. */
  77430. dispose(): void;
  77431. }
  77432. }
  77433. declare module BABYLON.GUI {
  77434. /**
  77435. * Abstract class used to create a container panel deployed on the surface of a volume
  77436. */
  77437. export abstract class VolumeBasedPanel extends Container3D {
  77438. private _columns;
  77439. private _rows;
  77440. private _rowThenColum;
  77441. private _orientation;
  77442. protected _cellWidth: number;
  77443. protected _cellHeight: number;
  77444. /**
  77445. * Gets or sets the distance between elements
  77446. */
  77447. margin: number;
  77448. /**
  77449. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77450. * | Value | Type | Description |
  77451. * | ----- | ----------------------------------- | ----------- |
  77452. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77453. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77454. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77455. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77456. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77457. */
  77458. get orientation(): number;
  77459. set orientation(value: number);
  77460. /**
  77461. * Gets or sets the number of columns requested (10 by default).
  77462. * The panel will automatically compute the number of rows based on number of child controls.
  77463. */
  77464. get columns(): BABYLON.int;
  77465. set columns(value: BABYLON.int);
  77466. /**
  77467. * Gets or sets a the number of rows requested.
  77468. * The panel will automatically compute the number of columns based on number of child controls.
  77469. */
  77470. get rows(): BABYLON.int;
  77471. set rows(value: BABYLON.int);
  77472. /**
  77473. * Creates new VolumeBasedPanel
  77474. */
  77475. constructor();
  77476. protected _arrangeChildren(): void;
  77477. /** Child classes must implement this function to provide correct control positioning */
  77478. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77479. /** Child classes can implement this function to provide additional processing */
  77480. protected _finalProcessing(): void;
  77481. }
  77482. }
  77483. declare module BABYLON.GUI {
  77484. /**
  77485. * Class used to create a container panel deployed on the surface of a cylinder
  77486. */
  77487. export class CylinderPanel extends VolumeBasedPanel {
  77488. private _radius;
  77489. /**
  77490. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  77491. */
  77492. get radius(): BABYLON.float;
  77493. set radius(value: BABYLON.float);
  77494. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77495. private _cylindricalMapping;
  77496. }
  77497. }
  77498. declare module BABYLON.GUI {
  77499. /** @hidden */
  77500. export var fluentVertexShader: {
  77501. name: string;
  77502. shader: string;
  77503. };
  77504. }
  77505. declare module BABYLON.GUI {
  77506. /** @hidden */
  77507. export var fluentPixelShader: {
  77508. name: string;
  77509. shader: string;
  77510. };
  77511. }
  77512. declare module BABYLON.GUI {
  77513. /** @hidden */
  77514. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  77515. INNERGLOW: boolean;
  77516. BORDER: boolean;
  77517. HOVERLIGHT: boolean;
  77518. TEXTURE: boolean;
  77519. constructor();
  77520. }
  77521. /**
  77522. * Class used to render controls with fluent desgin
  77523. */
  77524. export class FluentMaterial extends BABYLON.PushMaterial {
  77525. /**
  77526. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  77527. */
  77528. innerGlowColorIntensity: number;
  77529. /**
  77530. * Gets or sets the inner glow color (white by default)
  77531. */
  77532. innerGlowColor: BABYLON.Color3;
  77533. /**
  77534. * Gets or sets alpha value (default is 1.0)
  77535. */
  77536. alpha: number;
  77537. /**
  77538. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  77539. */
  77540. albedoColor: BABYLON.Color3;
  77541. /**
  77542. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  77543. */
  77544. renderBorders: boolean;
  77545. /**
  77546. * Gets or sets border width (default is 0.5)
  77547. */
  77548. borderWidth: number;
  77549. /**
  77550. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  77551. */
  77552. edgeSmoothingValue: number;
  77553. /**
  77554. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  77555. */
  77556. borderMinValue: number;
  77557. /**
  77558. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  77559. */
  77560. renderHoverLight: boolean;
  77561. /**
  77562. * Gets or sets the radius used to render the hover light (default is 1.0)
  77563. */
  77564. hoverRadius: number;
  77565. /**
  77566. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  77567. */
  77568. hoverColor: BABYLON.Color4;
  77569. /**
  77570. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  77571. */
  77572. hoverPosition: BABYLON.Vector3;
  77573. private _albedoTexture;
  77574. /** Gets or sets the texture to use for albedo color */
  77575. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77576. /**
  77577. * Creates a new Fluent material
  77578. * @param name defines the name of the material
  77579. * @param scene defines the hosting scene
  77580. */
  77581. constructor(name: string, scene: BABYLON.Scene);
  77582. needAlphaBlending(): boolean;
  77583. needAlphaTesting(): boolean;
  77584. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77585. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77586. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77587. getActiveTextures(): BABYLON.BaseTexture[];
  77588. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77589. dispose(forceDisposeEffect?: boolean): void;
  77590. clone(name: string): FluentMaterial;
  77591. serialize(): any;
  77592. getClassName(): string;
  77593. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  77594. }
  77595. }
  77596. declare module BABYLON.GUI {
  77597. /**
  77598. * Class used to create a holographic button in 3D
  77599. */
  77600. export class HolographicButton extends Button3D {
  77601. private _backPlate;
  77602. private _textPlate;
  77603. private _frontPlate;
  77604. private _text;
  77605. private _imageUrl;
  77606. private _shareMaterials;
  77607. private _frontMaterial;
  77608. private _backMaterial;
  77609. private _plateMaterial;
  77610. private _pickedPointObserver;
  77611. private _tooltipFade;
  77612. private _tooltipTextBlock;
  77613. private _tooltipTexture;
  77614. private _tooltipMesh;
  77615. private _tooltipHoverObserver;
  77616. private _tooltipOutObserver;
  77617. private _disposeTooltip;
  77618. /**
  77619. * Rendering ground id of all the mesh in the button
  77620. */
  77621. set renderingGroupId(id: number);
  77622. get renderingGroupId(): number;
  77623. /**
  77624. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  77625. */
  77626. set tooltipText(text: BABYLON.Nullable<string>);
  77627. get tooltipText(): BABYLON.Nullable<string>;
  77628. /**
  77629. * Gets or sets text for the button
  77630. */
  77631. get text(): string;
  77632. set text(value: string);
  77633. /**
  77634. * Gets or sets the image url for the button
  77635. */
  77636. get imageUrl(): string;
  77637. set imageUrl(value: string);
  77638. /**
  77639. * Gets the back material used by this button
  77640. */
  77641. get backMaterial(): FluentMaterial;
  77642. /**
  77643. * Gets the front material used by this button
  77644. */
  77645. get frontMaterial(): FluentMaterial;
  77646. /**
  77647. * Gets the plate material used by this button
  77648. */
  77649. get plateMaterial(): BABYLON.StandardMaterial;
  77650. /**
  77651. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  77652. */
  77653. get shareMaterials(): boolean;
  77654. /**
  77655. * Creates a new button
  77656. * @param name defines the control name
  77657. */
  77658. constructor(name?: string, shareMaterials?: boolean);
  77659. protected _getTypeName(): string;
  77660. private _rebuildContent;
  77661. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77662. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77663. private _createBackMaterial;
  77664. private _createFrontMaterial;
  77665. private _createPlateMaterial;
  77666. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  77667. /**
  77668. * Releases all associated resources
  77669. */
  77670. dispose(): void;
  77671. }
  77672. }
  77673. declare module BABYLON.GUI {
  77674. /**
  77675. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  77676. */
  77677. export class MeshButton3D extends Button3D {
  77678. /** @hidden */
  77679. protected _currentMesh: BABYLON.Mesh;
  77680. /**
  77681. * Creates a new 3D button based on a mesh
  77682. * @param mesh mesh to become a 3D button
  77683. * @param name defines the control name
  77684. */
  77685. constructor(mesh: BABYLON.Mesh, name?: string);
  77686. protected _getTypeName(): string;
  77687. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77688. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77689. }
  77690. }
  77691. declare module BABYLON.GUI {
  77692. /**
  77693. * Class used to create a container panel deployed on the surface of a plane
  77694. */
  77695. export class PlanePanel extends VolumeBasedPanel {
  77696. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77697. }
  77698. }
  77699. declare module BABYLON.GUI {
  77700. /**
  77701. * Class used to create a container panel where items get randomized planar mapping
  77702. */
  77703. export class ScatterPanel extends VolumeBasedPanel {
  77704. private _iteration;
  77705. /**
  77706. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  77707. */
  77708. get iteration(): BABYLON.float;
  77709. set iteration(value: BABYLON.float);
  77710. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77711. private _scatterMapping;
  77712. protected _finalProcessing(): void;
  77713. }
  77714. }
  77715. declare module BABYLON.GUI {
  77716. /**
  77717. * Class used to create a container panel deployed on the surface of a sphere
  77718. */
  77719. export class SpherePanel extends VolumeBasedPanel {
  77720. private _radius;
  77721. /**
  77722. * Gets or sets the radius of the sphere where to project controls (5 by default)
  77723. */
  77724. get radius(): BABYLON.float;
  77725. set radius(value: BABYLON.float);
  77726. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  77727. private _sphericalMapping;
  77728. }
  77729. }
  77730. declare module BABYLON.GUI {
  77731. /**
  77732. * Class used to create a stack panel in 3D on XY plane
  77733. */
  77734. export class StackPanel3D extends Container3D {
  77735. private _isVertical;
  77736. /**
  77737. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  77738. */
  77739. get isVertical(): boolean;
  77740. set isVertical(value: boolean);
  77741. /**
  77742. * Gets or sets the distance between elements
  77743. */
  77744. margin: number;
  77745. /**
  77746. * Creates new StackPanel
  77747. * @param isVertical
  77748. */
  77749. constructor(isVertical?: boolean);
  77750. protected _arrangeChildren(): void;
  77751. }
  77752. }
  77753. declare module BABYLON {
  77754. /**
  77755. * Configuration for glTF validation
  77756. */
  77757. export interface IGLTFValidationConfiguration {
  77758. /**
  77759. * The url of the glTF validator.
  77760. */
  77761. url: string;
  77762. }
  77763. /**
  77764. * glTF validation
  77765. */
  77766. export class GLTFValidation {
  77767. /**
  77768. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  77769. */
  77770. static Configuration: IGLTFValidationConfiguration;
  77771. private static _LoadScriptPromise;
  77772. /**
  77773. * Validate a glTF asset using the glTF-Validator.
  77774. * @param data The JSON of a glTF or the array buffer of a binary glTF
  77775. * @param rootUrl The root url for the glTF
  77776. * @param fileName The file name for the glTF
  77777. * @param getExternalResource The callback to get external resources for the glTF validator
  77778. * @returns A promise that resolves with the glTF validation results once complete
  77779. */
  77780. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  77781. }
  77782. }
  77783. declare module BABYLON {
  77784. /**
  77785. * Mode that determines the coordinate system to use.
  77786. */
  77787. export enum GLTFLoaderCoordinateSystemMode {
  77788. /**
  77789. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  77790. */
  77791. AUTO = 0,
  77792. /**
  77793. * Sets the useRightHandedSystem flag on the scene.
  77794. */
  77795. FORCE_RIGHT_HANDED = 1
  77796. }
  77797. /**
  77798. * Mode that determines what animations will start.
  77799. */
  77800. export enum GLTFLoaderAnimationStartMode {
  77801. /**
  77802. * No animation will start.
  77803. */
  77804. NONE = 0,
  77805. /**
  77806. * The first animation will start.
  77807. */
  77808. FIRST = 1,
  77809. /**
  77810. * All animations will start.
  77811. */
  77812. ALL = 2
  77813. }
  77814. /**
  77815. * Interface that contains the data for the glTF asset.
  77816. */
  77817. export interface IGLTFLoaderData {
  77818. /**
  77819. * The object that represents the glTF JSON.
  77820. */
  77821. json: Object;
  77822. /**
  77823. * The BIN chunk of a binary glTF.
  77824. */
  77825. bin: Nullable<IDataBuffer>;
  77826. }
  77827. /**
  77828. * Interface for extending the loader.
  77829. */
  77830. export interface IGLTFLoaderExtension {
  77831. /**
  77832. * The name of this extension.
  77833. */
  77834. readonly name: string;
  77835. /**
  77836. * Defines whether this extension is enabled.
  77837. */
  77838. enabled: boolean;
  77839. /**
  77840. * Defines the order of this extension.
  77841. * The loader sorts the extensions using these values when loading.
  77842. */
  77843. order?: number;
  77844. }
  77845. /**
  77846. * Loader state.
  77847. */
  77848. export enum GLTFLoaderState {
  77849. /**
  77850. * The asset is loading.
  77851. */
  77852. LOADING = 0,
  77853. /**
  77854. * The asset is ready for rendering.
  77855. */
  77856. READY = 1,
  77857. /**
  77858. * The asset is completely loaded.
  77859. */
  77860. COMPLETE = 2
  77861. }
  77862. /** @hidden */
  77863. export interface IImportMeshAsyncOutput {
  77864. meshes: AbstractMesh[];
  77865. particleSystems: IParticleSystem[];
  77866. skeletons: Skeleton[];
  77867. animationGroups: AnimationGroup[];
  77868. lights: Light[];
  77869. transformNodes: TransformNode[];
  77870. }
  77871. /** @hidden */
  77872. export interface IGLTFLoader extends IDisposable {
  77873. readonly state: Nullable<GLTFLoaderState>;
  77874. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  77875. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  77876. }
  77877. /**
  77878. * File loader for loading glTF files into a scene.
  77879. */
  77880. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77881. /** @hidden */
  77882. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77883. /** @hidden */
  77884. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  77885. /**
  77886. * Raised when the asset has been parsed
  77887. */
  77888. onParsedObservable: Observable<IGLTFLoaderData>;
  77889. private _onParsedObserver;
  77890. /**
  77891. * Raised when the asset has been parsed
  77892. */
  77893. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  77894. /**
  77895. * 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.
  77896. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  77897. * Defaults to true.
  77898. * @hidden
  77899. */
  77900. static IncrementalLoading: boolean;
  77901. /**
  77902. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  77903. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  77904. * @hidden
  77905. */
  77906. static HomogeneousCoordinates: boolean;
  77907. /**
  77908. * The coordinate system mode. Defaults to AUTO.
  77909. */
  77910. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  77911. /**
  77912. * The animation start mode. Defaults to FIRST.
  77913. */
  77914. animationStartMode: GLTFLoaderAnimationStartMode;
  77915. /**
  77916. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  77917. */
  77918. compileMaterials: boolean;
  77919. /**
  77920. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  77921. */
  77922. useClipPlane: boolean;
  77923. /**
  77924. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  77925. */
  77926. compileShadowGenerators: boolean;
  77927. /**
  77928. * Defines if the Alpha blended materials are only applied as coverage.
  77929. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  77930. * If true, no extra effects are applied to transparent pixels.
  77931. */
  77932. transparencyAsCoverage: boolean;
  77933. /**
  77934. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  77935. * Enabling will disable offline support and glTF validator.
  77936. * Defaults to false.
  77937. */
  77938. useRangeRequests: boolean;
  77939. /**
  77940. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  77941. */
  77942. createInstances: boolean;
  77943. /**
  77944. * Function called before loading a url referenced by the asset.
  77945. */
  77946. preprocessUrlAsync: (url: string) => Promise<string>;
  77947. /**
  77948. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77949. */
  77950. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  77951. private _onMeshLoadedObserver;
  77952. /**
  77953. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  77954. */
  77955. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  77956. /**
  77957. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  77958. */
  77959. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  77960. private _onTextureLoadedObserver;
  77961. /**
  77962. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  77963. */
  77964. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  77965. /**
  77966. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  77967. */
  77968. readonly onMaterialLoadedObservable: Observable<Material>;
  77969. private _onMaterialLoadedObserver;
  77970. /**
  77971. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  77972. */
  77973. set onMaterialLoaded(callback: (material: Material) => void);
  77974. /**
  77975. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  77976. */
  77977. readonly onCameraLoadedObservable: Observable<Camera>;
  77978. private _onCameraLoadedObserver;
  77979. /**
  77980. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  77981. */
  77982. set onCameraLoaded(callback: (camera: Camera) => void);
  77983. /**
  77984. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  77985. * For assets with LODs, raised when all of the LODs are complete.
  77986. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77987. */
  77988. readonly onCompleteObservable: Observable<void>;
  77989. private _onCompleteObserver;
  77990. /**
  77991. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  77992. * For assets with LODs, raised when all of the LODs are complete.
  77993. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  77994. */
  77995. set onComplete(callback: () => void);
  77996. /**
  77997. * Observable raised when an error occurs.
  77998. */
  77999. readonly onErrorObservable: Observable<any>;
  78000. private _onErrorObserver;
  78001. /**
  78002. * Callback raised when an error occurs.
  78003. */
  78004. set onError(callback: (reason: any) => void);
  78005. /**
  78006. * Observable raised after the loader is disposed.
  78007. */
  78008. readonly onDisposeObservable: Observable<void>;
  78009. private _onDisposeObserver;
  78010. /**
  78011. * Callback raised after the loader is disposed.
  78012. */
  78013. set onDispose(callback: () => void);
  78014. /**
  78015. * Observable raised after a loader extension is created.
  78016. * Set additional options for a loader extension in this event.
  78017. */
  78018. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  78019. private _onExtensionLoadedObserver;
  78020. /**
  78021. * Callback raised after a loader extension is created.
  78022. */
  78023. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  78024. /**
  78025. * Defines if the loader logging is enabled.
  78026. */
  78027. get loggingEnabled(): boolean;
  78028. set loggingEnabled(value: boolean);
  78029. /**
  78030. * Defines if the loader should capture performance counters.
  78031. */
  78032. get capturePerformanceCounters(): boolean;
  78033. set capturePerformanceCounters(value: boolean);
  78034. /**
  78035. * Defines if the loader should validate the asset.
  78036. */
  78037. validate: boolean;
  78038. /**
  78039. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  78040. */
  78041. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  78042. private _onValidatedObserver;
  78043. /**
  78044. * Callback raised after a loader extension is created.
  78045. */
  78046. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  78047. private _loader;
  78048. /**
  78049. * Name of the loader ("gltf")
  78050. */
  78051. name: string;
  78052. /** @hidden */
  78053. extensions: ISceneLoaderPluginExtensions;
  78054. /**
  78055. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  78056. */
  78057. dispose(): void;
  78058. /** @hidden */
  78059. _clear(): void;
  78060. /** @hidden */
  78061. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78062. /** @hidden */
  78063. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78064. /** @hidden */
  78065. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78066. meshes: AbstractMesh[];
  78067. particleSystems: IParticleSystem[];
  78068. skeletons: Skeleton[];
  78069. animationGroups: AnimationGroup[];
  78070. }>;
  78071. /** @hidden */
  78072. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78073. /** @hidden */
  78074. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78075. /** @hidden */
  78076. canDirectLoad(data: string): boolean;
  78077. /** @hidden */
  78078. directLoad(scene: Scene, data: string): any;
  78079. /**
  78080. * The callback that allows custom handling of the root url based on the response url.
  78081. * @param rootUrl the original root url
  78082. * @param responseURL the response url if available
  78083. * @returns the new root url
  78084. */
  78085. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  78086. /** @hidden */
  78087. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  78088. /**
  78089. * The loader state or null if the loader is not active.
  78090. */
  78091. get loaderState(): Nullable<GLTFLoaderState>;
  78092. /**
  78093. * Returns a promise that resolves when the asset is completely loaded.
  78094. * @returns a promise that resolves when the asset is completely loaded.
  78095. */
  78096. whenCompleteAsync(): Promise<void>;
  78097. private _validate;
  78098. private _getLoader;
  78099. private _parseJson;
  78100. private _unpackBinaryAsync;
  78101. private _unpackBinaryV1Async;
  78102. private _unpackBinaryV2Async;
  78103. private static _parseVersion;
  78104. private static _compareVersion;
  78105. private static readonly _logSpaces;
  78106. private _logIndentLevel;
  78107. private _loggingEnabled;
  78108. /** @hidden */
  78109. _log: (message: string) => void;
  78110. /** @hidden */
  78111. _logOpen(message: string): void;
  78112. /** @hidden */
  78113. _logClose(): void;
  78114. private _logEnabled;
  78115. private _logDisabled;
  78116. private _capturePerformanceCounters;
  78117. /** @hidden */
  78118. _startPerformanceCounter: (counterName: string) => void;
  78119. /** @hidden */
  78120. _endPerformanceCounter: (counterName: string) => void;
  78121. private _startPerformanceCounterEnabled;
  78122. private _startPerformanceCounterDisabled;
  78123. private _endPerformanceCounterEnabled;
  78124. private _endPerformanceCounterDisabled;
  78125. }
  78126. }
  78127. declare module BABYLON.GLTF1 {
  78128. /**
  78129. * Enums
  78130. * @hidden
  78131. */
  78132. export enum EComponentType {
  78133. BYTE = 5120,
  78134. UNSIGNED_BYTE = 5121,
  78135. SHORT = 5122,
  78136. UNSIGNED_SHORT = 5123,
  78137. FLOAT = 5126
  78138. }
  78139. /** @hidden */
  78140. export enum EShaderType {
  78141. FRAGMENT = 35632,
  78142. VERTEX = 35633
  78143. }
  78144. /** @hidden */
  78145. export enum EParameterType {
  78146. BYTE = 5120,
  78147. UNSIGNED_BYTE = 5121,
  78148. SHORT = 5122,
  78149. UNSIGNED_SHORT = 5123,
  78150. INT = 5124,
  78151. UNSIGNED_INT = 5125,
  78152. FLOAT = 5126,
  78153. FLOAT_VEC2 = 35664,
  78154. FLOAT_VEC3 = 35665,
  78155. FLOAT_VEC4 = 35666,
  78156. INT_VEC2 = 35667,
  78157. INT_VEC3 = 35668,
  78158. INT_VEC4 = 35669,
  78159. BOOL = 35670,
  78160. BOOL_VEC2 = 35671,
  78161. BOOL_VEC3 = 35672,
  78162. BOOL_VEC4 = 35673,
  78163. FLOAT_MAT2 = 35674,
  78164. FLOAT_MAT3 = 35675,
  78165. FLOAT_MAT4 = 35676,
  78166. SAMPLER_2D = 35678
  78167. }
  78168. /** @hidden */
  78169. export enum ETextureWrapMode {
  78170. CLAMP_TO_EDGE = 33071,
  78171. MIRRORED_REPEAT = 33648,
  78172. REPEAT = 10497
  78173. }
  78174. /** @hidden */
  78175. export enum ETextureFilterType {
  78176. NEAREST = 9728,
  78177. LINEAR = 9728,
  78178. NEAREST_MIPMAP_NEAREST = 9984,
  78179. LINEAR_MIPMAP_NEAREST = 9985,
  78180. NEAREST_MIPMAP_LINEAR = 9986,
  78181. LINEAR_MIPMAP_LINEAR = 9987
  78182. }
  78183. /** @hidden */
  78184. export enum ETextureFormat {
  78185. ALPHA = 6406,
  78186. RGB = 6407,
  78187. RGBA = 6408,
  78188. LUMINANCE = 6409,
  78189. LUMINANCE_ALPHA = 6410
  78190. }
  78191. /** @hidden */
  78192. export enum ECullingType {
  78193. FRONT = 1028,
  78194. BACK = 1029,
  78195. FRONT_AND_BACK = 1032
  78196. }
  78197. /** @hidden */
  78198. export enum EBlendingFunction {
  78199. ZERO = 0,
  78200. ONE = 1,
  78201. SRC_COLOR = 768,
  78202. ONE_MINUS_SRC_COLOR = 769,
  78203. DST_COLOR = 774,
  78204. ONE_MINUS_DST_COLOR = 775,
  78205. SRC_ALPHA = 770,
  78206. ONE_MINUS_SRC_ALPHA = 771,
  78207. DST_ALPHA = 772,
  78208. ONE_MINUS_DST_ALPHA = 773,
  78209. CONSTANT_COLOR = 32769,
  78210. ONE_MINUS_CONSTANT_COLOR = 32770,
  78211. CONSTANT_ALPHA = 32771,
  78212. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78213. SRC_ALPHA_SATURATE = 776
  78214. }
  78215. /** @hidden */
  78216. export interface IGLTFProperty {
  78217. extensions?: {
  78218. [key: string]: any;
  78219. };
  78220. extras?: Object;
  78221. }
  78222. /** @hidden */
  78223. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78224. name?: string;
  78225. }
  78226. /** @hidden */
  78227. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78228. bufferView: string;
  78229. byteOffset: number;
  78230. byteStride: number;
  78231. count: number;
  78232. type: string;
  78233. componentType: EComponentType;
  78234. max?: number[];
  78235. min?: number[];
  78236. name?: string;
  78237. }
  78238. /** @hidden */
  78239. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78240. buffer: string;
  78241. byteOffset: number;
  78242. byteLength: number;
  78243. byteStride: number;
  78244. target?: number;
  78245. }
  78246. /** @hidden */
  78247. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78248. uri: string;
  78249. byteLength?: number;
  78250. type?: string;
  78251. }
  78252. /** @hidden */
  78253. export interface IGLTFShader extends IGLTFChildRootProperty {
  78254. uri: string;
  78255. type: EShaderType;
  78256. }
  78257. /** @hidden */
  78258. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78259. attributes: string[];
  78260. fragmentShader: string;
  78261. vertexShader: string;
  78262. }
  78263. /** @hidden */
  78264. export interface IGLTFTechniqueParameter {
  78265. type: number;
  78266. count?: number;
  78267. semantic?: string;
  78268. node?: string;
  78269. value?: number | boolean | string | Array<any>;
  78270. source?: string;
  78271. babylonValue?: any;
  78272. }
  78273. /** @hidden */
  78274. export interface IGLTFTechniqueCommonProfile {
  78275. lightingModel: string;
  78276. texcoordBindings: Object;
  78277. parameters?: Array<any>;
  78278. }
  78279. /** @hidden */
  78280. export interface IGLTFTechniqueStatesFunctions {
  78281. blendColor?: number[];
  78282. blendEquationSeparate?: number[];
  78283. blendFuncSeparate?: number[];
  78284. colorMask: boolean[];
  78285. cullFace: number[];
  78286. }
  78287. /** @hidden */
  78288. export interface IGLTFTechniqueStates {
  78289. enable: number[];
  78290. functions: IGLTFTechniqueStatesFunctions;
  78291. }
  78292. /** @hidden */
  78293. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78294. parameters: {
  78295. [key: string]: IGLTFTechniqueParameter;
  78296. };
  78297. program: string;
  78298. attributes: {
  78299. [key: string]: string;
  78300. };
  78301. uniforms: {
  78302. [key: string]: string;
  78303. };
  78304. states: IGLTFTechniqueStates;
  78305. }
  78306. /** @hidden */
  78307. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78308. technique?: string;
  78309. values: string[];
  78310. }
  78311. /** @hidden */
  78312. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78313. attributes: {
  78314. [key: string]: string;
  78315. };
  78316. indices: string;
  78317. material: string;
  78318. mode?: number;
  78319. }
  78320. /** @hidden */
  78321. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78322. primitives: IGLTFMeshPrimitive[];
  78323. }
  78324. /** @hidden */
  78325. export interface IGLTFImage extends IGLTFChildRootProperty {
  78326. uri: string;
  78327. }
  78328. /** @hidden */
  78329. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78330. magFilter?: number;
  78331. minFilter?: number;
  78332. wrapS?: number;
  78333. wrapT?: number;
  78334. }
  78335. /** @hidden */
  78336. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78337. sampler: string;
  78338. source: string;
  78339. format?: ETextureFormat;
  78340. internalFormat?: ETextureFormat;
  78341. target?: number;
  78342. type?: number;
  78343. babylonTexture?: Texture;
  78344. }
  78345. /** @hidden */
  78346. export interface IGLTFAmbienLight {
  78347. color?: number[];
  78348. }
  78349. /** @hidden */
  78350. export interface IGLTFDirectionalLight {
  78351. color?: number[];
  78352. }
  78353. /** @hidden */
  78354. export interface IGLTFPointLight {
  78355. color?: number[];
  78356. constantAttenuation?: number;
  78357. linearAttenuation?: number;
  78358. quadraticAttenuation?: number;
  78359. }
  78360. /** @hidden */
  78361. export interface IGLTFSpotLight {
  78362. color?: number[];
  78363. constantAttenuation?: number;
  78364. fallOfAngle?: number;
  78365. fallOffExponent?: number;
  78366. linearAttenuation?: number;
  78367. quadraticAttenuation?: number;
  78368. }
  78369. /** @hidden */
  78370. export interface IGLTFLight extends IGLTFChildRootProperty {
  78371. type: string;
  78372. }
  78373. /** @hidden */
  78374. export interface IGLTFCameraOrthographic {
  78375. xmag: number;
  78376. ymag: number;
  78377. zfar: number;
  78378. znear: number;
  78379. }
  78380. /** @hidden */
  78381. export interface IGLTFCameraPerspective {
  78382. aspectRatio: number;
  78383. yfov: number;
  78384. zfar: number;
  78385. znear: number;
  78386. }
  78387. /** @hidden */
  78388. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78389. type: string;
  78390. }
  78391. /** @hidden */
  78392. export interface IGLTFAnimationChannelTarget {
  78393. id: string;
  78394. path: string;
  78395. }
  78396. /** @hidden */
  78397. export interface IGLTFAnimationChannel {
  78398. sampler: string;
  78399. target: IGLTFAnimationChannelTarget;
  78400. }
  78401. /** @hidden */
  78402. export interface IGLTFAnimationSampler {
  78403. input: string;
  78404. output: string;
  78405. interpolation?: string;
  78406. }
  78407. /** @hidden */
  78408. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78409. channels?: IGLTFAnimationChannel[];
  78410. parameters?: {
  78411. [key: string]: string;
  78412. };
  78413. samplers?: {
  78414. [key: string]: IGLTFAnimationSampler;
  78415. };
  78416. }
  78417. /** @hidden */
  78418. export interface IGLTFNodeInstanceSkin {
  78419. skeletons: string[];
  78420. skin: string;
  78421. meshes: string[];
  78422. }
  78423. /** @hidden */
  78424. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78425. bindShapeMatrix: number[];
  78426. inverseBindMatrices: string;
  78427. jointNames: string[];
  78428. babylonSkeleton?: Skeleton;
  78429. }
  78430. /** @hidden */
  78431. export interface IGLTFNode extends IGLTFChildRootProperty {
  78432. camera?: string;
  78433. children: string[];
  78434. skin?: string;
  78435. jointName?: string;
  78436. light?: string;
  78437. matrix: number[];
  78438. mesh?: string;
  78439. meshes?: string[];
  78440. rotation?: number[];
  78441. scale?: number[];
  78442. translation?: number[];
  78443. babylonNode?: Node;
  78444. }
  78445. /** @hidden */
  78446. export interface IGLTFScene extends IGLTFChildRootProperty {
  78447. nodes: string[];
  78448. }
  78449. /** @hidden */
  78450. export interface IGLTFRuntime {
  78451. extensions: {
  78452. [key: string]: any;
  78453. };
  78454. accessors: {
  78455. [key: string]: IGLTFAccessor;
  78456. };
  78457. buffers: {
  78458. [key: string]: IGLTFBuffer;
  78459. };
  78460. bufferViews: {
  78461. [key: string]: IGLTFBufferView;
  78462. };
  78463. meshes: {
  78464. [key: string]: IGLTFMesh;
  78465. };
  78466. lights: {
  78467. [key: string]: IGLTFLight;
  78468. };
  78469. cameras: {
  78470. [key: string]: IGLTFCamera;
  78471. };
  78472. nodes: {
  78473. [key: string]: IGLTFNode;
  78474. };
  78475. images: {
  78476. [key: string]: IGLTFImage;
  78477. };
  78478. textures: {
  78479. [key: string]: IGLTFTexture;
  78480. };
  78481. shaders: {
  78482. [key: string]: IGLTFShader;
  78483. };
  78484. programs: {
  78485. [key: string]: IGLTFProgram;
  78486. };
  78487. samplers: {
  78488. [key: string]: IGLTFSampler;
  78489. };
  78490. techniques: {
  78491. [key: string]: IGLTFTechnique;
  78492. };
  78493. materials: {
  78494. [key: string]: IGLTFMaterial;
  78495. };
  78496. animations: {
  78497. [key: string]: IGLTFAnimation;
  78498. };
  78499. skins: {
  78500. [key: string]: IGLTFSkins;
  78501. };
  78502. currentScene?: Object;
  78503. scenes: {
  78504. [key: string]: IGLTFScene;
  78505. };
  78506. extensionsUsed: string[];
  78507. extensionsRequired?: string[];
  78508. buffersCount: number;
  78509. shaderscount: number;
  78510. scene: Scene;
  78511. rootUrl: string;
  78512. loadedBufferCount: number;
  78513. loadedBufferViews: {
  78514. [name: string]: ArrayBufferView;
  78515. };
  78516. loadedShaderCount: number;
  78517. importOnlyMeshes: boolean;
  78518. importMeshesNames?: string[];
  78519. dummyNodes: Node[];
  78520. forAssetContainer: boolean;
  78521. }
  78522. /** @hidden */
  78523. export interface INodeToRoot {
  78524. bone: Bone;
  78525. node: IGLTFNode;
  78526. id: string;
  78527. }
  78528. /** @hidden */
  78529. export interface IJointNode {
  78530. node: IGLTFNode;
  78531. id: string;
  78532. }
  78533. }
  78534. declare module BABYLON.GLTF1 {
  78535. /**
  78536. * Utils functions for GLTF
  78537. * @hidden
  78538. */
  78539. export class GLTFUtils {
  78540. /**
  78541. * Sets the given "parameter" matrix
  78542. * @param scene: the Scene object
  78543. * @param source: the source node where to pick the matrix
  78544. * @param parameter: the GLTF technique parameter
  78545. * @param uniformName: the name of the shader's uniform
  78546. * @param shaderMaterial: the shader material
  78547. */
  78548. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  78549. /**
  78550. * Sets the given "parameter" matrix
  78551. * @param shaderMaterial: the shader material
  78552. * @param uniform: the name of the shader's uniform
  78553. * @param value: the value of the uniform
  78554. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  78555. */
  78556. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  78557. /**
  78558. * Returns the wrap mode of the texture
  78559. * @param mode: the mode value
  78560. */
  78561. static GetWrapMode(mode: number): number;
  78562. /**
  78563. * Returns the byte stride giving an accessor
  78564. * @param accessor: the GLTF accessor objet
  78565. */
  78566. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  78567. /**
  78568. * Returns the texture filter mode giving a mode value
  78569. * @param mode: the filter mode value
  78570. */
  78571. static GetTextureFilterMode(mode: number): ETextureFilterType;
  78572. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  78573. /**
  78574. * Returns a buffer from its accessor
  78575. * @param gltfRuntime: the GLTF runtime
  78576. * @param accessor: the GLTF accessor
  78577. */
  78578. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  78579. /**
  78580. * Decodes a buffer view into a string
  78581. * @param view: the buffer view
  78582. */
  78583. static DecodeBufferToText(view: ArrayBufferView): string;
  78584. /**
  78585. * Returns the default material of gltf. Related to
  78586. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  78587. * @param scene: the Babylon.js scene
  78588. */
  78589. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  78590. private static _DefaultMaterial;
  78591. }
  78592. }
  78593. declare module BABYLON.GLTF1 {
  78594. /**
  78595. * Implementation of the base glTF spec
  78596. * @hidden
  78597. */
  78598. export class GLTFLoaderBase {
  78599. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  78600. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78601. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  78602. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78603. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  78604. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78605. }
  78606. /**
  78607. * glTF V1 Loader
  78608. * @hidden
  78609. */
  78610. export class GLTFLoader implements IGLTFLoader {
  78611. static Extensions: {
  78612. [name: string]: GLTFLoaderExtension;
  78613. };
  78614. static RegisterExtension(extension: GLTFLoaderExtension): void;
  78615. state: Nullable<GLTFLoaderState>;
  78616. dispose(): void;
  78617. private _importMeshAsync;
  78618. /**
  78619. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  78620. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78621. * @param scene the scene the meshes should be added to
  78622. * @param forAssetContainer defines if the entities must be stored in the scene
  78623. * @param data gltf data containing information of the meshes in a loaded file
  78624. * @param rootUrl root url to load from
  78625. * @param onProgress event that fires when loading progress has occured
  78626. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78627. */
  78628. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  78629. private _loadAsync;
  78630. /**
  78631. * Imports all objects from a loaded gltf file and adds them to the scene
  78632. * @param scene the scene the objects should be added to
  78633. * @param data gltf data containing information of the meshes in a loaded file
  78634. * @param rootUrl root url to load from
  78635. * @param onProgress event that fires when loading progress has occured
  78636. * @returns a promise which completes when objects have been loaded to the scene
  78637. */
  78638. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  78639. private _loadShadersAsync;
  78640. private _loadBuffersAsync;
  78641. private _createNodes;
  78642. }
  78643. /** @hidden */
  78644. export abstract class GLTFLoaderExtension {
  78645. private _name;
  78646. constructor(name: string);
  78647. get name(): string;
  78648. /**
  78649. * Defines an override for loading the runtime
  78650. * Return true to stop further extensions from loading the runtime
  78651. */
  78652. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  78653. /**
  78654. * Defines an onverride for creating gltf runtime
  78655. * Return true to stop further extensions from creating the runtime
  78656. */
  78657. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  78658. /**
  78659. * Defines an override for loading buffers
  78660. * Return true to stop further extensions from loading this buffer
  78661. */
  78662. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  78663. /**
  78664. * Defines an override for loading texture buffers
  78665. * Return true to stop further extensions from loading this texture data
  78666. */
  78667. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78668. /**
  78669. * Defines an override for creating textures
  78670. * Return true to stop further extensions from loading this texture
  78671. */
  78672. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  78673. /**
  78674. * Defines an override for loading shader strings
  78675. * Return true to stop further extensions from loading this shader data
  78676. */
  78677. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78678. /**
  78679. * Defines an override for loading materials
  78680. * Return true to stop further extensions from loading this material
  78681. */
  78682. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78683. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  78684. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  78685. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  78686. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  78687. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  78688. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  78689. private static LoadTextureBufferAsync;
  78690. private static CreateTextureAsync;
  78691. private static ApplyExtensions;
  78692. }
  78693. }
  78694. declare module BABYLON.GLTF1 {
  78695. /** @hidden */
  78696. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  78697. private _bin;
  78698. constructor();
  78699. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  78700. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78701. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  78702. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  78703. }
  78704. }
  78705. declare module BABYLON.GLTF1 {
  78706. /** @hidden */
  78707. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  78708. constructor();
  78709. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  78710. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  78711. private _loadTexture;
  78712. }
  78713. }
  78714. declare module BABYLON.GLTF2.Loader {
  78715. /**
  78716. * Loader interface with an index field.
  78717. */
  78718. export interface IArrayItem {
  78719. /**
  78720. * The index of this item in the array.
  78721. */
  78722. index: number;
  78723. }
  78724. /**
  78725. * Loader interface with additional members.
  78726. */
  78727. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  78728. /** @hidden */
  78729. _data?: Promise<ArrayBufferView>;
  78730. /** @hidden */
  78731. _babylonVertexBuffer?: Promise<VertexBuffer>;
  78732. }
  78733. /**
  78734. * Loader interface with additional members.
  78735. */
  78736. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  78737. }
  78738. /** @hidden */
  78739. export interface _IAnimationSamplerData {
  78740. input: Float32Array;
  78741. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  78742. output: Float32Array;
  78743. }
  78744. /**
  78745. * Loader interface with additional members.
  78746. */
  78747. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  78748. /** @hidden */
  78749. _data?: Promise<_IAnimationSamplerData>;
  78750. }
  78751. /**
  78752. * Loader interface with additional members.
  78753. */
  78754. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  78755. channels: IAnimationChannel[];
  78756. samplers: IAnimationSampler[];
  78757. /** @hidden */
  78758. _babylonAnimationGroup?: AnimationGroup;
  78759. }
  78760. /**
  78761. * Loader interface with additional members.
  78762. */
  78763. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  78764. /** @hidden */
  78765. _data?: Promise<ArrayBufferView>;
  78766. }
  78767. /**
  78768. * Loader interface with additional members.
  78769. */
  78770. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  78771. /** @hidden */
  78772. _data?: Promise<ArrayBufferView>;
  78773. /** @hidden */
  78774. _babylonBuffer?: Promise<Buffer>;
  78775. }
  78776. /**
  78777. * Loader interface with additional members.
  78778. */
  78779. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  78780. }
  78781. /**
  78782. * Loader interface with additional members.
  78783. */
  78784. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  78785. /** @hidden */
  78786. _data?: Promise<ArrayBufferView>;
  78787. }
  78788. /**
  78789. * Loader interface with additional members.
  78790. */
  78791. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  78792. }
  78793. /**
  78794. * Loader interface with additional members.
  78795. */
  78796. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  78797. }
  78798. /**
  78799. * Loader interface with additional members.
  78800. */
  78801. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  78802. baseColorTexture?: ITextureInfo;
  78803. metallicRoughnessTexture?: ITextureInfo;
  78804. }
  78805. /**
  78806. * Loader interface with additional members.
  78807. */
  78808. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  78809. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78810. normalTexture?: IMaterialNormalTextureInfo;
  78811. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78812. emissiveTexture?: ITextureInfo;
  78813. /** @hidden */
  78814. _data?: {
  78815. [babylonDrawMode: number]: {
  78816. babylonMaterial: Material;
  78817. babylonMeshes: AbstractMesh[];
  78818. promise: Promise<void>;
  78819. };
  78820. };
  78821. }
  78822. /**
  78823. * Loader interface with additional members.
  78824. */
  78825. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  78826. primitives: IMeshPrimitive[];
  78827. }
  78828. /**
  78829. * Loader interface with additional members.
  78830. */
  78831. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  78832. /** @hidden */
  78833. _instanceData?: {
  78834. babylonSourceMesh: Mesh;
  78835. promise: Promise<any>;
  78836. };
  78837. }
  78838. /**
  78839. * Loader interface with additional members.
  78840. */
  78841. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  78842. /**
  78843. * The parent glTF node.
  78844. */
  78845. parent?: INode;
  78846. /** @hidden */
  78847. _babylonTransformNode?: TransformNode;
  78848. /** @hidden */
  78849. _primitiveBabylonMeshes?: AbstractMesh[];
  78850. /** @hidden */
  78851. _babylonBones?: Bone[];
  78852. /** @hidden */
  78853. _numMorphTargets?: number;
  78854. }
  78855. /** @hidden */
  78856. export interface _ISamplerData {
  78857. noMipMaps: boolean;
  78858. samplingMode: number;
  78859. wrapU: number;
  78860. wrapV: number;
  78861. }
  78862. /**
  78863. * Loader interface with additional members.
  78864. */
  78865. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  78866. /** @hidden */
  78867. _data?: _ISamplerData;
  78868. }
  78869. /**
  78870. * Loader interface with additional members.
  78871. */
  78872. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  78873. }
  78874. /**
  78875. * Loader interface with additional members.
  78876. */
  78877. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  78878. /** @hidden */
  78879. _data?: {
  78880. babylonSkeleton: Skeleton;
  78881. promise: Promise<void>;
  78882. };
  78883. }
  78884. /**
  78885. * Loader interface with additional members.
  78886. */
  78887. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  78888. }
  78889. /**
  78890. * Loader interface with additional members.
  78891. */
  78892. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  78893. }
  78894. /**
  78895. * Loader interface with additional members.
  78896. */
  78897. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  78898. accessors?: IAccessor[];
  78899. animations?: IAnimation[];
  78900. buffers?: IBuffer[];
  78901. bufferViews?: IBufferView[];
  78902. cameras?: ICamera[];
  78903. images?: IImage[];
  78904. materials?: IMaterial[];
  78905. meshes?: IMesh[];
  78906. nodes?: INode[];
  78907. samplers?: ISampler[];
  78908. scenes?: IScene[];
  78909. skins?: ISkin[];
  78910. textures?: ITexture[];
  78911. }
  78912. }
  78913. declare module BABYLON.GLTF2 {
  78914. /**
  78915. * Interface for a glTF loader extension.
  78916. */
  78917. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  78918. /**
  78919. * Called after the loader state changes to LOADING.
  78920. */
  78921. onLoading?(): void;
  78922. /**
  78923. * Called after the loader state changes to READY.
  78924. */
  78925. onReady?(): void;
  78926. /**
  78927. * Define this method to modify the default behavior when loading scenes.
  78928. * @param context The context when loading the asset
  78929. * @param scene The glTF scene property
  78930. * @returns A promise that resolves when the load is complete or null if not handled
  78931. */
  78932. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  78933. /**
  78934. * Define this method to modify the default behavior when loading nodes.
  78935. * @param context The context when loading the asset
  78936. * @param node The glTF node property
  78937. * @param assign A function called synchronously after parsing the glTF properties
  78938. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  78939. */
  78940. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78941. /**
  78942. * Define this method to modify the default behavior when loading cameras.
  78943. * @param context The context when loading the asset
  78944. * @param camera The glTF camera property
  78945. * @param assign A function called synchronously after parsing the glTF properties
  78946. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  78947. */
  78948. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  78949. /**
  78950. * @hidden
  78951. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  78952. * @param context The context when loading the asset
  78953. * @param primitive The glTF mesh primitive property
  78954. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  78955. */
  78956. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78957. /**
  78958. * @hidden
  78959. * Define this method to modify the default behavior when loading data for mesh primitives.
  78960. * @param context The context when loading the asset
  78961. * @param name The mesh name when loading the asset
  78962. * @param node The glTF node when loading the asset
  78963. * @param mesh The glTF mesh when loading the asset
  78964. * @param primitive The glTF mesh primitive property
  78965. * @param assign A function called synchronously after parsing the glTF properties
  78966. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78967. */
  78968. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78969. /**
  78970. * @hidden
  78971. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  78972. * @param context The context when loading the asset
  78973. * @param material The glTF material property
  78974. * @param assign A function called synchronously after parsing the glTF properties
  78975. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  78976. */
  78977. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  78978. /**
  78979. * Define this method to modify the default behavior when creating materials.
  78980. * @param context The context when loading the asset
  78981. * @param material The glTF material property
  78982. * @param babylonDrawMode The draw mode for the Babylon material
  78983. * @returns The Babylon material or null if not handled
  78984. */
  78985. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  78986. /**
  78987. * Define this method to modify the default behavior when loading material properties.
  78988. * @param context The context when loading the asset
  78989. * @param material The glTF material property
  78990. * @param babylonMaterial The Babylon material
  78991. * @returns A promise that resolves when the load is complete or null if not handled
  78992. */
  78993. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78994. /**
  78995. * Define this method to modify the default behavior when loading texture infos.
  78996. * @param context The context when loading the asset
  78997. * @param textureInfo The glTF texture info property
  78998. * @param assign A function called synchronously after parsing the glTF properties
  78999. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79000. */
  79001. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79002. /**
  79003. * @hidden
  79004. * Define this method to modify the default behavior when loading textures.
  79005. * @param context The context when loading the asset
  79006. * @param texture The glTF texture property
  79007. * @param assign A function called synchronously after parsing the glTF properties
  79008. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79009. */
  79010. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79011. /**
  79012. * Define this method to modify the default behavior when loading animations.
  79013. * @param context The context when loading the asset
  79014. * @param animation The glTF animation property
  79015. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  79016. */
  79017. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79018. /**
  79019. * @hidden
  79020. * Define this method to modify the default behavior when loading skins.
  79021. * @param context The context when loading the asset
  79022. * @param node The glTF node property
  79023. * @param skin The glTF skin property
  79024. * @returns A promise that resolves when the load is complete or null if not handled
  79025. */
  79026. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  79027. /**
  79028. * @hidden
  79029. * Define this method to modify the default behavior when loading uris.
  79030. * @param context The context when loading the asset
  79031. * @param property The glTF property associated with the uri
  79032. * @param uri The uri to load
  79033. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79034. */
  79035. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79036. /**
  79037. * Define this method to modify the default behavior when loading buffer views.
  79038. * @param context The context when loading the asset
  79039. * @param bufferView The glTF buffer view property
  79040. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79041. */
  79042. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  79043. /**
  79044. * Define this method to modify the default behavior when loading buffers.
  79045. * @param context The context when loading the asset
  79046. * @param buffer The glTF buffer property
  79047. * @param byteOffset The byte offset to load
  79048. * @param byteLength The byte length to load
  79049. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79050. */
  79051. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79052. }
  79053. }
  79054. declare module BABYLON.GLTF2 {
  79055. /**
  79056. * Helper class for working with arrays when loading the glTF asset
  79057. */
  79058. export class ArrayItem {
  79059. /**
  79060. * Gets an item from the given array.
  79061. * @param context The context when loading the asset
  79062. * @param array The array to get the item from
  79063. * @param index The index to the array
  79064. * @returns The array item
  79065. */
  79066. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  79067. /**
  79068. * Assign an `index` field to each item of the given array.
  79069. * @param array The array of items
  79070. */
  79071. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  79072. }
  79073. /**
  79074. * The glTF 2.0 loader
  79075. */
  79076. export class GLTFLoader implements IGLTFLoader {
  79077. /** @hidden */
  79078. _completePromises: Promise<any>[];
  79079. /** @hidden */
  79080. _forAssetContainer: boolean;
  79081. /** Storage */
  79082. _babylonLights: Light[];
  79083. /** @hidden */
  79084. _disableInstancedMesh: number;
  79085. private _disposed;
  79086. private _parent;
  79087. private _state;
  79088. private _extensions;
  79089. private _rootUrl;
  79090. private _fileName;
  79091. private _uniqueRootUrl;
  79092. private _gltf;
  79093. private _bin;
  79094. private _babylonScene;
  79095. private _rootBabylonMesh;
  79096. private _defaultBabylonMaterialData;
  79097. private _progressCallback?;
  79098. private _requests;
  79099. private static _RegisteredExtensions;
  79100. /**
  79101. * The default glTF sampler.
  79102. */
  79103. static readonly DefaultSampler: ISampler;
  79104. /**
  79105. * Registers a loader extension.
  79106. * @param name The name of the loader extension.
  79107. * @param factory The factory function that creates the loader extension.
  79108. */
  79109. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  79110. /**
  79111. * Unregisters a loader extension.
  79112. * @param name The name of the loader extension.
  79113. * @returns A boolean indicating whether the extension has been unregistered
  79114. */
  79115. static UnregisterExtension(name: string): boolean;
  79116. /**
  79117. * The loader state.
  79118. */
  79119. get state(): Nullable<GLTFLoaderState>;
  79120. /**
  79121. * The object that represents the glTF JSON.
  79122. */
  79123. get gltf(): IGLTF;
  79124. /**
  79125. * The BIN chunk of a binary glTF.
  79126. */
  79127. get bin(): Nullable<IDataBuffer>;
  79128. /**
  79129. * The parent file loader.
  79130. */
  79131. get parent(): GLTFFileLoader;
  79132. /**
  79133. * The Babylon scene when loading the asset.
  79134. */
  79135. get babylonScene(): Scene;
  79136. /**
  79137. * The root Babylon mesh when loading the asset.
  79138. */
  79139. get rootBabylonMesh(): Mesh;
  79140. /** @hidden */
  79141. constructor(parent: GLTFFileLoader);
  79142. /** @hidden */
  79143. dispose(): void;
  79144. /** @hidden */
  79145. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79146. /** @hidden */
  79147. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79148. private _loadAsync;
  79149. private _loadData;
  79150. private _setupData;
  79151. private _loadExtensions;
  79152. private _checkExtensions;
  79153. private _setState;
  79154. private _createRootNode;
  79155. /**
  79156. * Loads a glTF scene.
  79157. * @param context The context when loading the asset
  79158. * @param scene The glTF scene property
  79159. * @returns A promise that resolves when the load is complete
  79160. */
  79161. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79162. private _forEachPrimitive;
  79163. private _getMeshes;
  79164. private _getTransformNodes;
  79165. private _getSkeletons;
  79166. private _getAnimationGroups;
  79167. private _startAnimations;
  79168. /**
  79169. * Loads a glTF node.
  79170. * @param context The context when loading the asset
  79171. * @param node The glTF node property
  79172. * @param assign A function called synchronously after parsing the glTF properties
  79173. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79174. */
  79175. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79176. private _loadMeshAsync;
  79177. /**
  79178. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79179. * @param context The context when loading the asset
  79180. * @param name The mesh name when loading the asset
  79181. * @param node The glTF node when loading the asset
  79182. * @param mesh The glTF mesh when loading the asset
  79183. * @param primitive The glTF mesh primitive property
  79184. * @param assign A function called synchronously after parsing the glTF properties
  79185. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79186. */
  79187. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79188. private _loadVertexDataAsync;
  79189. private _createMorphTargets;
  79190. private _loadMorphTargetsAsync;
  79191. private _loadMorphTargetVertexDataAsync;
  79192. private static _LoadTransform;
  79193. private _loadSkinAsync;
  79194. private _loadBones;
  79195. private _loadBone;
  79196. private _loadSkinInverseBindMatricesDataAsync;
  79197. private _updateBoneMatrices;
  79198. private _getNodeMatrix;
  79199. /**
  79200. * Loads a glTF camera.
  79201. * @param context The context when loading the asset
  79202. * @param camera The glTF camera property
  79203. * @param assign A function called synchronously after parsing the glTF properties
  79204. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79205. */
  79206. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79207. private _loadAnimationsAsync;
  79208. /**
  79209. * Loads a glTF animation.
  79210. * @param context The context when loading the asset
  79211. * @param animation The glTF animation property
  79212. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79213. */
  79214. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79215. /**
  79216. * @hidden Loads a glTF animation channel.
  79217. * @param context The context when loading the asset
  79218. * @param animationContext The context of the animation when loading the asset
  79219. * @param animation The glTF animation property
  79220. * @param channel The glTF animation channel property
  79221. * @param babylonAnimationGroup The babylon animation group property
  79222. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79223. * @returns A void promise when the channel load is complete
  79224. */
  79225. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79226. private _loadAnimationSamplerAsync;
  79227. private _loadBufferAsync;
  79228. /**
  79229. * Loads a glTF buffer view.
  79230. * @param context The context when loading the asset
  79231. * @param bufferView The glTF buffer view property
  79232. * @returns A promise that resolves with the loaded data when the load is complete
  79233. */
  79234. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79235. private _loadAccessorAsync;
  79236. /** @hidden */
  79237. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79238. private _loadIndicesAccessorAsync;
  79239. private _loadVertexBufferViewAsync;
  79240. private _loadVertexAccessorAsync;
  79241. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79242. /** @hidden */
  79243. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79244. private _createDefaultMaterial;
  79245. /**
  79246. * Creates a Babylon material from a glTF material.
  79247. * @param context The context when loading the asset
  79248. * @param material The glTF material property
  79249. * @param babylonDrawMode The draw mode for the Babylon material
  79250. * @returns The Babylon material
  79251. */
  79252. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79253. /**
  79254. * Loads properties from a glTF material into a Babylon material.
  79255. * @param context The context when loading the asset
  79256. * @param material The glTF material property
  79257. * @param babylonMaterial The Babylon material
  79258. * @returns A promise that resolves when the load is complete
  79259. */
  79260. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79261. /**
  79262. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79263. * @param context The context when loading the asset
  79264. * @param material The glTF material property
  79265. * @param babylonMaterial The Babylon material
  79266. * @returns A promise that resolves when the load is complete
  79267. */
  79268. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79269. /**
  79270. * Loads the alpha properties from a glTF material into a Babylon material.
  79271. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79272. * @param context The context when loading the asset
  79273. * @param material The glTF material property
  79274. * @param babylonMaterial The Babylon material
  79275. */
  79276. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79277. /**
  79278. * Loads a glTF texture info.
  79279. * @param context The context when loading the asset
  79280. * @param textureInfo The glTF texture info property
  79281. * @param assign A function called synchronously after parsing the glTF properties
  79282. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79283. */
  79284. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79285. /** @hidden */
  79286. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79287. /** @hidden */
  79288. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79289. private _loadSampler;
  79290. /**
  79291. * Loads a glTF image.
  79292. * @param context The context when loading the asset
  79293. * @param image The glTF image property
  79294. * @returns A promise that resolves with the loaded data when the load is complete
  79295. */
  79296. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79297. /**
  79298. * Loads a glTF uri.
  79299. * @param context The context when loading the asset
  79300. * @param property The glTF property associated with the uri
  79301. * @param uri The base64 or relative uri
  79302. * @returns A promise that resolves with the loaded data when the load is complete
  79303. */
  79304. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79305. private _onProgress;
  79306. /**
  79307. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79308. * @param babylonObject the Babylon object with metadata
  79309. * @param pointer the JSON pointer
  79310. */
  79311. static AddPointerMetadata(babylonObject: {
  79312. metadata: any;
  79313. }, pointer: string): void;
  79314. private static _GetTextureWrapMode;
  79315. private static _GetTextureSamplingMode;
  79316. private static _GetTypedArrayConstructor;
  79317. private static _GetTypedArray;
  79318. private static _GetNumComponents;
  79319. private static _ValidateUri;
  79320. private static _GetDrawMode;
  79321. private _compileMaterialsAsync;
  79322. private _compileShadowGeneratorsAsync;
  79323. private _forEachExtensions;
  79324. private _applyExtensions;
  79325. private _extensionsOnLoading;
  79326. private _extensionsOnReady;
  79327. private _extensionsLoadSceneAsync;
  79328. private _extensionsLoadNodeAsync;
  79329. private _extensionsLoadCameraAsync;
  79330. private _extensionsLoadVertexDataAsync;
  79331. private _extensionsLoadMeshPrimitiveAsync;
  79332. private _extensionsLoadMaterialAsync;
  79333. private _extensionsCreateMaterial;
  79334. private _extensionsLoadMaterialPropertiesAsync;
  79335. private _extensionsLoadTextureInfoAsync;
  79336. private _extensionsLoadTextureAsync;
  79337. private _extensionsLoadAnimationAsync;
  79338. private _extensionsLoadSkinAsync;
  79339. private _extensionsLoadUriAsync;
  79340. private _extensionsLoadBufferViewAsync;
  79341. private _extensionsLoadBufferAsync;
  79342. /**
  79343. * Helper method called by a loader extension to load an glTF extension.
  79344. * @param context The context when loading the asset
  79345. * @param property The glTF property to load the extension from
  79346. * @param extensionName The name of the extension to load
  79347. * @param actionAsync The action to run
  79348. * @returns The promise returned by actionAsync or null if the extension does not exist
  79349. */
  79350. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79351. /**
  79352. * Helper method called by a loader extension to load a glTF extra.
  79353. * @param context The context when loading the asset
  79354. * @param property The glTF property to load the extra from
  79355. * @param extensionName The name of the extension to load
  79356. * @param actionAsync The action to run
  79357. * @returns The promise returned by actionAsync or null if the extra does not exist
  79358. */
  79359. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79360. /**
  79361. * Checks for presence of an extension.
  79362. * @param name The name of the extension to check
  79363. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79364. */
  79365. isExtensionUsed(name: string): boolean;
  79366. /**
  79367. * Increments the indentation level and logs a message.
  79368. * @param message The message to log
  79369. */
  79370. logOpen(message: string): void;
  79371. /**
  79372. * Decrements the indentation level.
  79373. */
  79374. logClose(): void;
  79375. /**
  79376. * Logs a message
  79377. * @param message The message to log
  79378. */
  79379. log(message: string): void;
  79380. /**
  79381. * Starts a performance counter.
  79382. * @param counterName The name of the performance counter
  79383. */
  79384. startPerformanceCounter(counterName: string): void;
  79385. /**
  79386. * Ends a performance counter.
  79387. * @param counterName The name of the performance counter
  79388. */
  79389. endPerformanceCounter(counterName: string): void;
  79390. }
  79391. }
  79392. declare module BABYLON.GLTF2.Loader.Extensions {
  79393. /**
  79394. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79395. */
  79396. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79397. /**
  79398. * The name of this extension.
  79399. */
  79400. readonly name: string;
  79401. /**
  79402. * Defines whether this extension is enabled.
  79403. */
  79404. enabled: boolean;
  79405. private _loader;
  79406. private _lights?;
  79407. /** @hidden */
  79408. constructor(loader: GLTFLoader);
  79409. /** @hidden */
  79410. dispose(): void;
  79411. /** @hidden */
  79412. onLoading(): void;
  79413. /** @hidden */
  79414. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79415. private _loadLightAsync;
  79416. }
  79417. }
  79418. declare module BABYLON.GLTF2.Loader.Extensions {
  79419. /**
  79420. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79421. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79422. * !!! Experimental Extension Subject to Changes !!!
  79423. */
  79424. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79425. /**
  79426. * The name of this extension.
  79427. */
  79428. readonly name: string;
  79429. /**
  79430. * Defines whether this extension is enabled.
  79431. */
  79432. enabled: boolean;
  79433. private _loader;
  79434. /** @hidden */
  79435. constructor(loader: GLTFLoader);
  79436. /** @hidden */
  79437. dispose(): void;
  79438. /** @hidden */
  79439. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79440. }
  79441. }
  79442. declare module BABYLON.GLTF2.Loader.Extensions {
  79443. /**
  79444. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79445. */
  79446. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79447. /**
  79448. * The name of this extension.
  79449. */
  79450. readonly name: string;
  79451. /**
  79452. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79453. */
  79454. dracoCompression?: DracoCompression;
  79455. /**
  79456. * Defines whether this extension is enabled.
  79457. */
  79458. enabled: boolean;
  79459. private _loader;
  79460. /** @hidden */
  79461. constructor(loader: GLTFLoader);
  79462. /** @hidden */
  79463. dispose(): void;
  79464. /** @hidden */
  79465. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79466. }
  79467. }
  79468. declare module BABYLON.GLTF2.Loader.Extensions {
  79469. /**
  79470. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79471. */
  79472. export class KHR_lights implements IGLTFLoaderExtension {
  79473. /**
  79474. * The name of this extension.
  79475. */
  79476. readonly name: string;
  79477. /**
  79478. * Defines whether this extension is enabled.
  79479. */
  79480. enabled: boolean;
  79481. private _loader;
  79482. private _lights?;
  79483. /** @hidden */
  79484. constructor(loader: GLTFLoader);
  79485. /** @hidden */
  79486. dispose(): void;
  79487. /** @hidden */
  79488. onLoading(): void;
  79489. /** @hidden */
  79490. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79491. }
  79492. }
  79493. declare module BABYLON.GLTF2.Loader.Extensions {
  79494. /**
  79495. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  79496. */
  79497. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  79498. /**
  79499. * The name of this extension.
  79500. */
  79501. readonly name: string;
  79502. /**
  79503. * Defines whether this extension is enabled.
  79504. */
  79505. enabled: boolean;
  79506. /**
  79507. * Defines a number that determines the order the extensions are applied.
  79508. */
  79509. order: number;
  79510. private _loader;
  79511. /** @hidden */
  79512. constructor(loader: GLTFLoader);
  79513. /** @hidden */
  79514. dispose(): void;
  79515. /** @hidden */
  79516. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79517. private _loadSpecularGlossinessPropertiesAsync;
  79518. }
  79519. }
  79520. declare module BABYLON.GLTF2.Loader.Extensions {
  79521. /**
  79522. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  79523. */
  79524. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  79525. /**
  79526. * The name of this extension.
  79527. */
  79528. readonly name: string;
  79529. /**
  79530. * Defines whether this extension is enabled.
  79531. */
  79532. enabled: boolean;
  79533. /**
  79534. * Defines a number that determines the order the extensions are applied.
  79535. */
  79536. order: number;
  79537. private _loader;
  79538. /** @hidden */
  79539. constructor(loader: GLTFLoader);
  79540. /** @hidden */
  79541. dispose(): void;
  79542. /** @hidden */
  79543. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79544. private _loadUnlitPropertiesAsync;
  79545. }
  79546. }
  79547. declare module BABYLON.GLTF2.Loader.Extensions {
  79548. /**
  79549. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  79550. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  79551. * !!! Experimental Extension Subject to Changes !!!
  79552. */
  79553. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  79554. /**
  79555. * The name of this extension.
  79556. */
  79557. readonly name: string;
  79558. /**
  79559. * Defines whether this extension is enabled.
  79560. */
  79561. enabled: boolean;
  79562. /**
  79563. * Defines a number that determines the order the extensions are applied.
  79564. */
  79565. order: number;
  79566. private _loader;
  79567. /** @hidden */
  79568. constructor(loader: GLTFLoader);
  79569. /** @hidden */
  79570. dispose(): void;
  79571. /** @hidden */
  79572. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79573. private _loadClearCoatPropertiesAsync;
  79574. }
  79575. }
  79576. declare module BABYLON.GLTF2.Loader.Extensions {
  79577. /**
  79578. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  79579. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  79580. * !!! Experimental Extension Subject to Changes !!!
  79581. */
  79582. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  79583. /**
  79584. * The name of this extension.
  79585. */
  79586. readonly name: string;
  79587. /**
  79588. * Defines whether this extension is enabled.
  79589. */
  79590. enabled: boolean;
  79591. /**
  79592. * Defines a number that determines the order the extensions are applied.
  79593. */
  79594. order: number;
  79595. private _loader;
  79596. /** @hidden */
  79597. constructor(loader: GLTFLoader);
  79598. /** @hidden */
  79599. dispose(): void;
  79600. /** @hidden */
  79601. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79602. private _loadSheenPropertiesAsync;
  79603. }
  79604. }
  79605. declare module BABYLON.GLTF2.Loader.Extensions {
  79606. /**
  79607. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  79608. * !!! Experimental Extension Subject to Changes !!!
  79609. */
  79610. export class KHR_materials_specular implements IGLTFLoaderExtension {
  79611. /**
  79612. * The name of this extension.
  79613. */
  79614. readonly name: string;
  79615. /**
  79616. * Defines whether this extension is enabled.
  79617. */
  79618. enabled: boolean;
  79619. /**
  79620. * Defines a number that determines the order the extensions are applied.
  79621. */
  79622. order: number;
  79623. private _loader;
  79624. /** @hidden */
  79625. constructor(loader: GLTFLoader);
  79626. /** @hidden */
  79627. dispose(): void;
  79628. /** @hidden */
  79629. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79630. private _loadSpecularPropertiesAsync;
  79631. }
  79632. }
  79633. declare module BABYLON.GLTF2.Loader.Extensions {
  79634. /**
  79635. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  79636. * !!! Experimental Extension Subject to Changes !!!
  79637. */
  79638. export class KHR_materials_ior implements IGLTFLoaderExtension {
  79639. /**
  79640. * Default ior Value from the spec.
  79641. */
  79642. private static readonly _DEFAULT_IOR;
  79643. /**
  79644. * The name of this extension.
  79645. */
  79646. readonly name: string;
  79647. /**
  79648. * Defines whether this extension is enabled.
  79649. */
  79650. enabled: boolean;
  79651. /**
  79652. * Defines a number that determines the order the extensions are applied.
  79653. */
  79654. order: number;
  79655. private _loader;
  79656. /** @hidden */
  79657. constructor(loader: GLTFLoader);
  79658. /** @hidden */
  79659. dispose(): void;
  79660. /** @hidden */
  79661. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79662. private _loadIorPropertiesAsync;
  79663. }
  79664. }
  79665. declare module BABYLON.GLTF2.Loader.Extensions {
  79666. /**
  79667. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  79668. */
  79669. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  79670. /**
  79671. * The name of this extension.
  79672. */
  79673. readonly name: string;
  79674. /**
  79675. * Defines whether this extension is enabled.
  79676. */
  79677. enabled: boolean;
  79678. /** @hidden */
  79679. constructor(loader: GLTFLoader);
  79680. /** @hidden */
  79681. dispose(): void;
  79682. }
  79683. }
  79684. declare module BABYLON.GLTF2.Loader.Extensions {
  79685. /**
  79686. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  79687. * !!! Experimental Extension Subject to Changes !!!
  79688. */
  79689. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  79690. /** The name of this extension. */
  79691. readonly name: string;
  79692. /** Defines whether this extension is enabled. */
  79693. enabled: boolean;
  79694. private _loader;
  79695. /** @hidden */
  79696. constructor(loader: GLTFLoader);
  79697. /** @hidden */
  79698. dispose(): void;
  79699. /** @hidden */
  79700. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79701. }
  79702. }
  79703. declare module BABYLON.GLTF2.Loader.Extensions {
  79704. /**
  79705. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  79706. */
  79707. export class KHR_texture_transform implements IGLTFLoaderExtension {
  79708. /**
  79709. * The name of this extension.
  79710. */
  79711. readonly name: string;
  79712. /**
  79713. * Defines whether this extension is enabled.
  79714. */
  79715. enabled: boolean;
  79716. private _loader;
  79717. /** @hidden */
  79718. constructor(loader: GLTFLoader);
  79719. /** @hidden */
  79720. dispose(): void;
  79721. /** @hidden */
  79722. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79723. }
  79724. }
  79725. declare module BABYLON.GLTF2.Loader.Extensions {
  79726. /**
  79727. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  79728. * !!! Experimental Extension Subject to Changes !!!
  79729. */
  79730. export class KHR_xmp implements IGLTFLoaderExtension {
  79731. /**
  79732. * The name of this extension.
  79733. */
  79734. readonly name: string;
  79735. /**
  79736. * Defines whether this extension is enabled.
  79737. */
  79738. enabled: boolean;
  79739. /**
  79740. * Defines a number that determines the order the extensions are applied.
  79741. */
  79742. order: number;
  79743. private _loader;
  79744. /** @hidden */
  79745. constructor(loader: GLTFLoader);
  79746. /** @hidden */
  79747. dispose(): void;
  79748. /**
  79749. * Called after the loader state changes to LOADING.
  79750. */
  79751. onLoading(): void;
  79752. }
  79753. }
  79754. declare module BABYLON.GLTF2.Loader.Extensions {
  79755. /**
  79756. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  79757. */
  79758. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  79759. /**
  79760. * The name of this extension.
  79761. */
  79762. readonly name: string;
  79763. /**
  79764. * Defines whether this extension is enabled.
  79765. */
  79766. enabled: boolean;
  79767. private _loader;
  79768. private _clips;
  79769. private _emitters;
  79770. /** @hidden */
  79771. constructor(loader: GLTFLoader);
  79772. /** @hidden */
  79773. dispose(): void;
  79774. /** @hidden */
  79775. onLoading(): void;
  79776. /** @hidden */
  79777. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79778. /** @hidden */
  79779. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79780. /** @hidden */
  79781. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79782. private _loadClipAsync;
  79783. private _loadEmitterAsync;
  79784. private _getEventAction;
  79785. private _loadAnimationEventAsync;
  79786. }
  79787. }
  79788. declare module BABYLON.GLTF2.Loader.Extensions {
  79789. /**
  79790. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  79791. */
  79792. export class MSFT_lod implements IGLTFLoaderExtension {
  79793. /**
  79794. * The name of this extension.
  79795. */
  79796. readonly name: string;
  79797. /**
  79798. * Defines whether this extension is enabled.
  79799. */
  79800. enabled: boolean;
  79801. /**
  79802. * Defines a number that determines the order the extensions are applied.
  79803. */
  79804. order: number;
  79805. /**
  79806. * Maximum number of LODs to load, starting from the lowest LOD.
  79807. */
  79808. maxLODsToLoad: number;
  79809. /**
  79810. * Observable raised when all node LODs of one level are loaded.
  79811. * The event data is the index of the loaded LOD starting from zero.
  79812. * Dispose the loader to cancel the loading of the next level of LODs.
  79813. */
  79814. onNodeLODsLoadedObservable: Observable<number>;
  79815. /**
  79816. * Observable raised when all material LODs of one level are loaded.
  79817. * The event data is the index of the loaded LOD starting from zero.
  79818. * Dispose the loader to cancel the loading of the next level of LODs.
  79819. */
  79820. onMaterialLODsLoadedObservable: Observable<number>;
  79821. private _loader;
  79822. private _nodeIndexLOD;
  79823. private _nodeSignalLODs;
  79824. private _nodePromiseLODs;
  79825. private _materialIndexLOD;
  79826. private _materialSignalLODs;
  79827. private _materialPromiseLODs;
  79828. private _indexLOD;
  79829. private _bufferLODs;
  79830. /** @hidden */
  79831. constructor(loader: GLTFLoader);
  79832. /** @hidden */
  79833. dispose(): void;
  79834. /** @hidden */
  79835. onReady(): void;
  79836. /** @hidden */
  79837. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79838. /** @hidden */
  79839. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79840. /** @hidden */
  79841. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79842. /** @hidden */
  79843. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79844. /** @hidden */
  79845. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79846. private _loadBufferLOD;
  79847. /**
  79848. * Gets an array of LOD properties from lowest to highest.
  79849. */
  79850. private _getLODs;
  79851. private _disposeTransformNode;
  79852. private _disposeMaterials;
  79853. }
  79854. }
  79855. declare module BABYLON.GLTF2.Loader.Extensions {
  79856. /** @hidden */
  79857. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  79858. readonly name: string;
  79859. enabled: boolean;
  79860. private _loader;
  79861. constructor(loader: GLTFLoader);
  79862. dispose(): void;
  79863. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79864. }
  79865. }
  79866. declare module BABYLON.GLTF2.Loader.Extensions {
  79867. /** @hidden */
  79868. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  79869. readonly name: string;
  79870. enabled: boolean;
  79871. private _loader;
  79872. constructor(loader: GLTFLoader);
  79873. dispose(): void;
  79874. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79875. }
  79876. }
  79877. declare module BABYLON.GLTF2.Loader.Extensions {
  79878. /**
  79879. * Store glTF extras (if present) in BJS objects' metadata
  79880. */
  79881. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  79882. /**
  79883. * The name of this extension.
  79884. */
  79885. readonly name: string;
  79886. /**
  79887. * Defines whether this extension is enabled.
  79888. */
  79889. enabled: boolean;
  79890. private _loader;
  79891. private _assignExtras;
  79892. /** @hidden */
  79893. constructor(loader: GLTFLoader);
  79894. /** @hidden */
  79895. dispose(): void;
  79896. /** @hidden */
  79897. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79898. /** @hidden */
  79899. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79900. /** @hidden */
  79901. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79902. }
  79903. }
  79904. declare module BABYLON {
  79905. /**
  79906. * Class reading and parsing the MTL file bundled with the obj file.
  79907. */
  79908. export class MTLFileLoader {
  79909. /**
  79910. * Invert Y-Axis of referenced textures on load
  79911. */
  79912. static INVERT_TEXTURE_Y: boolean;
  79913. /**
  79914. * All material loaded from the mtl will be set here
  79915. */
  79916. materials: StandardMaterial[];
  79917. /**
  79918. * This function will read the mtl file and create each material described inside
  79919. * This function could be improve by adding :
  79920. * -some component missing (Ni, Tf...)
  79921. * -including the specific options available
  79922. *
  79923. * @param scene defines the scene the material will be created in
  79924. * @param data defines the mtl data to parse
  79925. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  79926. * @param forAssetContainer defines if the material should be registered in the scene
  79927. */
  79928. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  79929. /**
  79930. * Gets the texture for the material.
  79931. *
  79932. * If the material is imported from input file,
  79933. * We sanitize the url to ensure it takes the textre from aside the material.
  79934. *
  79935. * @param rootUrl The root url to load from
  79936. * @param value The value stored in the mtl
  79937. * @return The Texture
  79938. */
  79939. private static _getTexture;
  79940. }
  79941. }
  79942. declare module BABYLON {
  79943. /**
  79944. * Options for loading OBJ/MTL files
  79945. */
  79946. type MeshLoadOptions = {
  79947. /**
  79948. * Defines if UVs are optimized by default during load.
  79949. */
  79950. OptimizeWithUV: boolean;
  79951. /**
  79952. * Defines custom scaling of UV coordinates of loaded meshes.
  79953. */
  79954. UVScaling: Vector2;
  79955. /**
  79956. * Invert model on y-axis (does a model scaling inversion)
  79957. */
  79958. InvertY: boolean;
  79959. /**
  79960. * Invert Y-Axis of referenced textures on load
  79961. */
  79962. InvertTextureY: boolean;
  79963. /**
  79964. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  79965. */
  79966. ImportVertexColors: boolean;
  79967. /**
  79968. * Compute the normals for the model, even if normals are present in the file.
  79969. */
  79970. ComputeNormals: boolean;
  79971. /**
  79972. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  79973. */
  79974. SkipMaterials: boolean;
  79975. /**
  79976. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  79977. */
  79978. MaterialLoadingFailsSilently: boolean;
  79979. };
  79980. /**
  79981. * OBJ file type loader.
  79982. * This is a babylon scene loader plugin.
  79983. */
  79984. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79985. /**
  79986. * Defines if UVs are optimized by default during load.
  79987. */
  79988. static OPTIMIZE_WITH_UV: boolean;
  79989. /**
  79990. * Invert model on y-axis (does a model scaling inversion)
  79991. */
  79992. static INVERT_Y: boolean;
  79993. /**
  79994. * Invert Y-Axis of referenced textures on load
  79995. */
  79996. static get INVERT_TEXTURE_Y(): boolean;
  79997. static set INVERT_TEXTURE_Y(value: boolean);
  79998. /**
  79999. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80000. */
  80001. static IMPORT_VERTEX_COLORS: boolean;
  80002. /**
  80003. * Compute the normals for the model, even if normals are present in the file.
  80004. */
  80005. static COMPUTE_NORMALS: boolean;
  80006. /**
  80007. * Defines custom scaling of UV coordinates of loaded meshes.
  80008. */
  80009. static UV_SCALING: Vector2;
  80010. /**
  80011. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80012. */
  80013. static SKIP_MATERIALS: boolean;
  80014. /**
  80015. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80016. *
  80017. * Defaults to true for backwards compatibility.
  80018. */
  80019. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  80020. /**
  80021. * Defines the name of the plugin.
  80022. */
  80023. name: string;
  80024. /**
  80025. * Defines the extension the plugin is able to load.
  80026. */
  80027. extensions: string;
  80028. /** @hidden */
  80029. obj: RegExp;
  80030. /** @hidden */
  80031. group: RegExp;
  80032. /** @hidden */
  80033. mtllib: RegExp;
  80034. /** @hidden */
  80035. usemtl: RegExp;
  80036. /** @hidden */
  80037. smooth: RegExp;
  80038. /** @hidden */
  80039. vertexPattern: RegExp;
  80040. /** @hidden */
  80041. normalPattern: RegExp;
  80042. /** @hidden */
  80043. uvPattern: RegExp;
  80044. /** @hidden */
  80045. facePattern1: RegExp;
  80046. /** @hidden */
  80047. facePattern2: RegExp;
  80048. /** @hidden */
  80049. facePattern3: RegExp;
  80050. /** @hidden */
  80051. facePattern4: RegExp;
  80052. /** @hidden */
  80053. facePattern5: RegExp;
  80054. private _forAssetContainer;
  80055. private _meshLoadOptions;
  80056. /**
  80057. * Creates loader for .OBJ files
  80058. *
  80059. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  80060. */
  80061. constructor(meshLoadOptions?: MeshLoadOptions);
  80062. private static get currentMeshLoadOptions();
  80063. /**
  80064. * Calls synchronously the MTL file attached to this obj.
  80065. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  80066. * Without this function materials are not displayed in the first frame (but displayed after).
  80067. * In consequence it is impossible to get material information in your HTML file
  80068. *
  80069. * @param url The URL of the MTL file
  80070. * @param rootUrl
  80071. * @param onSuccess Callback function to be called when the MTL file is loaded
  80072. * @private
  80073. */
  80074. private _loadMTL;
  80075. /**
  80076. * Instantiates a OBJ file loader plugin.
  80077. * @returns the created plugin
  80078. */
  80079. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  80080. /**
  80081. * If the data string can be loaded directly.
  80082. *
  80083. * @param data string containing the file data
  80084. * @returns if the data can be loaded directly
  80085. */
  80086. canDirectLoad(data: string): boolean;
  80087. /**
  80088. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  80089. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80090. * @param scene the scene the meshes should be added to
  80091. * @param data the OBJ data to load
  80092. * @param rootUrl root url to load from
  80093. * @param onProgress event that fires when loading progress has occured
  80094. * @param fileName Defines the name of the file to load
  80095. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80096. */
  80097. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80098. meshes: AbstractMesh[];
  80099. particleSystems: IParticleSystem[];
  80100. skeletons: Skeleton[];
  80101. animationGroups: AnimationGroup[];
  80102. }>;
  80103. /**
  80104. * Imports all objects from the loaded OBJ data and adds them to the scene
  80105. * @param scene the scene the objects should be added to
  80106. * @param data the OBJ data to load
  80107. * @param rootUrl root url to load from
  80108. * @param onProgress event that fires when loading progress has occured
  80109. * @param fileName Defines the name of the file to load
  80110. * @returns a promise which completes when objects have been loaded to the scene
  80111. */
  80112. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80113. /**
  80114. * Load into an asset container.
  80115. * @param scene The scene to load into
  80116. * @param data The data to import
  80117. * @param rootUrl The root url for scene and resources
  80118. * @param onProgress The callback when the load progresses
  80119. * @param fileName Defines the name of the file to load
  80120. * @returns The loaded asset container
  80121. */
  80122. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80123. /**
  80124. * Read the OBJ file and create an Array of meshes.
  80125. * Each mesh contains all information given by the OBJ and the MTL file.
  80126. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  80127. *
  80128. * @param meshesNames
  80129. * @param scene Scene The scene where are displayed the data
  80130. * @param data String The content of the obj file
  80131. * @param rootUrl String The path to the folder
  80132. * @returns Array<AbstractMesh>
  80133. * @private
  80134. */
  80135. private _parseSolid;
  80136. }
  80137. }
  80138. declare module BABYLON {
  80139. /**
  80140. * STL file type loader.
  80141. * This is a babylon scene loader plugin.
  80142. */
  80143. export class STLFileLoader implements ISceneLoaderPlugin {
  80144. /** @hidden */
  80145. solidPattern: RegExp;
  80146. /** @hidden */
  80147. facetsPattern: RegExp;
  80148. /** @hidden */
  80149. normalPattern: RegExp;
  80150. /** @hidden */
  80151. vertexPattern: RegExp;
  80152. /**
  80153. * Defines the name of the plugin.
  80154. */
  80155. name: string;
  80156. /**
  80157. * Defines the extensions the stl loader is able to load.
  80158. * force data to come in as an ArrayBuffer
  80159. * we'll convert to string if it looks like it's an ASCII .stl
  80160. */
  80161. extensions: ISceneLoaderPluginExtensions;
  80162. /**
  80163. * Import meshes into a scene.
  80164. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80165. * @param scene The scene to import into
  80166. * @param data The data to import
  80167. * @param rootUrl The root url for scene and resources
  80168. * @param meshes The meshes array to import into
  80169. * @param particleSystems The particle systems array to import into
  80170. * @param skeletons The skeletons array to import into
  80171. * @param onError The callback when import fails
  80172. * @returns True if successful or false otherwise
  80173. */
  80174. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80175. /**
  80176. * Load into a scene.
  80177. * @param scene The scene to load into
  80178. * @param data The data to import
  80179. * @param rootUrl The root url for scene and resources
  80180. * @param onError The callback when import fails
  80181. * @returns true if successful or false otherwise
  80182. */
  80183. load(scene: Scene, data: any, rootUrl: string): boolean;
  80184. /**
  80185. * Load into an asset container.
  80186. * @param scene The scene to load into
  80187. * @param data The data to import
  80188. * @param rootUrl The root url for scene and resources
  80189. * @param onError The callback when import fails
  80190. * @returns The loaded asset container
  80191. */
  80192. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80193. private _isBinary;
  80194. private _parseBinary;
  80195. private _parseASCII;
  80196. }
  80197. }
  80198. declare module BABYLON {
  80199. /**
  80200. * Class for generating OBJ data from a Babylon scene.
  80201. */
  80202. export class OBJExport {
  80203. /**
  80204. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80205. * @param mesh defines the list of meshes to serialize
  80206. * @param materials defines if materials should be exported
  80207. * @param matlibname defines the name of the associated mtl file
  80208. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80209. * @returns the OBJ content
  80210. */
  80211. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80212. /**
  80213. * Exports the material(s) of a mesh in .MTL file format (text)
  80214. * @param mesh defines the mesh to extract the material from
  80215. * @returns the mtl content
  80216. */
  80217. static MTL(mesh: Mesh): string;
  80218. }
  80219. }
  80220. declare module BABYLON {
  80221. /** @hidden */
  80222. export var __IGLTFExporterExtension: number;
  80223. /**
  80224. * Interface for extending the exporter
  80225. * @hidden
  80226. */
  80227. export interface IGLTFExporterExtension {
  80228. /**
  80229. * The name of this extension
  80230. */
  80231. readonly name: string;
  80232. /**
  80233. * Defines whether this extension is enabled
  80234. */
  80235. enabled: boolean;
  80236. /**
  80237. * Defines whether this extension is required
  80238. */
  80239. required: boolean;
  80240. }
  80241. }
  80242. declare module BABYLON.GLTF2.Exporter {
  80243. /** @hidden */
  80244. export var __IGLTFExporterExtensionV2: number;
  80245. /**
  80246. * Interface for a glTF exporter extension
  80247. * @hidden
  80248. */
  80249. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80250. /**
  80251. * Define this method to modify the default behavior before exporting a texture
  80252. * @param context The context when loading the asset
  80253. * @param babylonTexture The Babylon.js texture
  80254. * @param mimeType The mime-type of the generated image
  80255. * @returns A promise that resolves with the exported texture
  80256. */
  80257. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80258. /**
  80259. * Define this method to get notified when a texture info is created
  80260. * @param context The context when loading the asset
  80261. * @param textureInfo The glTF texture info
  80262. * @param babylonTexture The Babylon.js texture
  80263. */
  80264. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80265. /**
  80266. * Define this method to modify the default behavior when exporting texture info
  80267. * @param context The context when loading the asset
  80268. * @param meshPrimitive glTF mesh primitive
  80269. * @param babylonSubMesh Babylon submesh
  80270. * @param binaryWriter glTF serializer binary writer instance
  80271. * @returns nullable IMeshPrimitive promise
  80272. */
  80273. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80274. /**
  80275. * Define this method to modify the default behavior when exporting a node
  80276. * @param context The context when exporting the node
  80277. * @param node glTF node
  80278. * @param babylonNode BabylonJS node
  80279. * @returns nullable INode promise
  80280. */
  80281. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80282. [key: number]: number;
  80283. }): Promise<Nullable<INode>>;
  80284. /**
  80285. * Define this method to modify the default behavior when exporting a material
  80286. * @param material glTF material
  80287. * @param babylonMaterial BabylonJS material
  80288. * @returns nullable IMaterial promise
  80289. */
  80290. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80291. /**
  80292. * Define this method to return additional textures to export from a material
  80293. * @param material glTF material
  80294. * @param babylonMaterial BabylonJS material
  80295. * @returns List of textures
  80296. */
  80297. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80298. /** Gets a boolean indicating that this extension was used */
  80299. wasUsed: boolean;
  80300. /** Gets a boolean indicating that this extension is required for the file to work */
  80301. required: boolean;
  80302. /**
  80303. * Called after the exporter state changes to EXPORTING
  80304. */
  80305. onExporting?(): void;
  80306. }
  80307. }
  80308. declare module BABYLON.GLTF2.Exporter {
  80309. /**
  80310. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80311. * @hidden
  80312. */
  80313. export class _GLTFMaterialExporter {
  80314. /**
  80315. * Represents the dielectric specular values for R, G and B
  80316. */
  80317. private static readonly _DielectricSpecular;
  80318. /**
  80319. * Allows the maximum specular power to be defined for material calculations
  80320. */
  80321. private static readonly _MaxSpecularPower;
  80322. /**
  80323. * Mapping to store textures
  80324. */
  80325. private _textureMap;
  80326. /**
  80327. * Numeric tolerance value
  80328. */
  80329. private static readonly _Epsilon;
  80330. /**
  80331. * Reference to the glTF Exporter
  80332. */
  80333. private _exporter;
  80334. constructor(exporter: _Exporter);
  80335. /**
  80336. * Specifies if two colors are approximately equal in value
  80337. * @param color1 first color to compare to
  80338. * @param color2 second color to compare to
  80339. * @param epsilon threshold value
  80340. */
  80341. private static FuzzyEquals;
  80342. /**
  80343. * Gets the materials from a Babylon scene and converts them to glTF materials
  80344. * @param scene babylonjs scene
  80345. * @param mimeType texture mime type
  80346. * @param images array of images
  80347. * @param textures array of textures
  80348. * @param materials array of materials
  80349. * @param imageData mapping of texture names to base64 textures
  80350. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80351. */
  80352. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80353. /**
  80354. * Makes a copy of the glTF material without the texture parameters
  80355. * @param originalMaterial original glTF material
  80356. * @returns glTF material without texture parameters
  80357. */
  80358. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80359. /**
  80360. * Specifies if the material has any texture parameters present
  80361. * @param material glTF Material
  80362. * @returns boolean specifying if texture parameters are present
  80363. */
  80364. _hasTexturesPresent(material: IMaterial): boolean;
  80365. /**
  80366. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80367. * @param babylonStandardMaterial
  80368. * @returns glTF Metallic Roughness Material representation
  80369. */
  80370. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80371. /**
  80372. * Computes the metallic factor
  80373. * @param diffuse diffused value
  80374. * @param specular specular value
  80375. * @param oneMinusSpecularStrength one minus the specular strength
  80376. * @returns metallic value
  80377. */
  80378. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80379. /**
  80380. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80381. * @param glTFMaterial glTF material
  80382. * @param babylonMaterial Babylon material
  80383. */
  80384. private static _SetAlphaMode;
  80385. /**
  80386. * Converts a Babylon Standard Material to a glTF Material
  80387. * @param babylonStandardMaterial BJS Standard Material
  80388. * @param mimeType mime type to use for the textures
  80389. * @param images array of glTF image interfaces
  80390. * @param textures array of glTF texture interfaces
  80391. * @param materials array of glTF material interfaces
  80392. * @param imageData map of image file name to data
  80393. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80394. */
  80395. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80396. private _finishMaterial;
  80397. /**
  80398. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80399. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80400. * @param mimeType mime type to use for the textures
  80401. * @param images array of glTF image interfaces
  80402. * @param textures array of glTF texture interfaces
  80403. * @param materials array of glTF material interfaces
  80404. * @param imageData map of image file name to data
  80405. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80406. */
  80407. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80408. /**
  80409. * Converts an image typed array buffer to a base64 image
  80410. * @param buffer typed array buffer
  80411. * @param width width of the image
  80412. * @param height height of the image
  80413. * @param mimeType mimetype of the image
  80414. * @returns base64 image string
  80415. */
  80416. private _createBase64FromCanvasAsync;
  80417. /**
  80418. * Generates a white texture based on the specified width and height
  80419. * @param width width of the texture in pixels
  80420. * @param height height of the texture in pixels
  80421. * @param scene babylonjs scene
  80422. * @returns white texture
  80423. */
  80424. private _createWhiteTexture;
  80425. /**
  80426. * 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
  80427. * @param texture1 first texture to resize
  80428. * @param texture2 second texture to resize
  80429. * @param scene babylonjs scene
  80430. * @returns resized textures or null
  80431. */
  80432. private _resizeTexturesToSameDimensions;
  80433. /**
  80434. * Converts an array of pixels to a Float32Array
  80435. * Throws an error if the pixel format is not supported
  80436. * @param pixels - array buffer containing pixel values
  80437. * @returns Float32 of pixels
  80438. */
  80439. private _convertPixelArrayToFloat32;
  80440. /**
  80441. * Convert Specular Glossiness Textures to Metallic Roughness
  80442. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  80443. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  80444. * @param diffuseTexture texture used to store diffuse information
  80445. * @param specularGlossinessTexture texture used to store specular and glossiness information
  80446. * @param factors specular glossiness material factors
  80447. * @param mimeType the mime type to use for the texture
  80448. * @returns pbr metallic roughness interface or null
  80449. */
  80450. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  80451. /**
  80452. * Converts specular glossiness material properties to metallic roughness
  80453. * @param specularGlossiness interface with specular glossiness material properties
  80454. * @returns interface with metallic roughness material properties
  80455. */
  80456. private _convertSpecularGlossinessToMetallicRoughness;
  80457. /**
  80458. * Calculates the surface reflectance, independent of lighting conditions
  80459. * @param color Color source to calculate brightness from
  80460. * @returns number representing the perceived brightness, or zero if color is undefined
  80461. */
  80462. private _getPerceivedBrightness;
  80463. /**
  80464. * Returns the maximum color component value
  80465. * @param color
  80466. * @returns maximum color component value, or zero if color is null or undefined
  80467. */
  80468. private _getMaxComponent;
  80469. /**
  80470. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  80471. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80472. * @param mimeType mime type to use for the textures
  80473. * @param images array of glTF image interfaces
  80474. * @param textures array of glTF texture interfaces
  80475. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80476. * @param imageData map of image file name to data
  80477. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80478. * @returns glTF PBR Metallic Roughness factors
  80479. */
  80480. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  80481. private _getGLTFTextureSampler;
  80482. private _getGLTFTextureWrapMode;
  80483. private _getGLTFTextureWrapModesSampler;
  80484. /**
  80485. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  80486. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80487. * @param mimeType mime type to use for the textures
  80488. * @param images array of glTF image interfaces
  80489. * @param textures array of glTF texture interfaces
  80490. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  80491. * @param imageData map of image file name to data
  80492. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80493. * @returns glTF PBR Metallic Roughness factors
  80494. */
  80495. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  80496. /**
  80497. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80498. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  80499. * @param mimeType mime type to use for the textures
  80500. * @param images array of glTF image interfaces
  80501. * @param textures array of glTF texture interfaces
  80502. * @param materials array of glTF material interfaces
  80503. * @param imageData map of image file name to data
  80504. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80505. */
  80506. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80507. private setMetallicRoughnessPbrMaterial;
  80508. private getPixelsFromTexture;
  80509. /**
  80510. * Extracts a texture from a Babylon texture into file data and glTF data
  80511. * @param babylonTexture Babylon texture to extract
  80512. * @param mimeType Mime Type of the babylonTexture
  80513. * @return glTF texture info, or null if the texture format is not supported
  80514. */
  80515. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80516. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  80517. /**
  80518. * Builds a texture from base64 string
  80519. * @param base64Texture base64 texture string
  80520. * @param baseTextureName Name to use for the texture
  80521. * @param mimeType image mime type for the texture
  80522. * @param images array of images
  80523. * @param textures array of textures
  80524. * @param imageData map of image data
  80525. * @returns glTF texture info, or null if the texture format is not supported
  80526. */
  80527. private _getTextureInfoFromBase64;
  80528. }
  80529. }
  80530. declare module BABYLON {
  80531. /**
  80532. * Class for holding and downloading glTF file data
  80533. */
  80534. export class GLTFData {
  80535. /**
  80536. * Object which contains the file name as the key and its data as the value
  80537. */
  80538. glTFFiles: {
  80539. [fileName: string]: string | Blob;
  80540. };
  80541. /**
  80542. * Initializes the glTF file object
  80543. */
  80544. constructor();
  80545. /**
  80546. * Downloads the glTF data as files based on their names and data
  80547. */
  80548. downloadFiles(): void;
  80549. }
  80550. }
  80551. declare module BABYLON {
  80552. /**
  80553. * Holds a collection of exporter options and parameters
  80554. */
  80555. export interface IExportOptions {
  80556. /**
  80557. * Function which indicates whether a babylon node should be exported or not
  80558. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  80559. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  80560. */
  80561. shouldExportNode?(node: Node): boolean;
  80562. /**
  80563. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  80564. * @param metadata source metadata to read from
  80565. * @returns the data to store to glTF node extras
  80566. */
  80567. metadataSelector?(metadata: any): any;
  80568. /**
  80569. * The sample rate to bake animation curves
  80570. */
  80571. animationSampleRate?: number;
  80572. /**
  80573. * Begin serialization without waiting for the scene to be ready
  80574. */
  80575. exportWithoutWaitingForScene?: boolean;
  80576. /**
  80577. * Indicates if coordinate system swapping root nodes should be included in export
  80578. */
  80579. includeCoordinateSystemConversionNodes?: boolean;
  80580. }
  80581. /**
  80582. * Class for generating glTF data from a Babylon scene.
  80583. */
  80584. export class GLTF2Export {
  80585. /**
  80586. * Exports the geometry of the scene to .gltf file format asynchronously
  80587. * @param scene Babylon scene with scene hierarchy information
  80588. * @param filePrefix File prefix to use when generating the glTF file
  80589. * @param options Exporter options
  80590. * @returns Returns an object with a .gltf file and associates texture names
  80591. * as keys and their data and paths as values
  80592. */
  80593. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80594. private static _PreExportAsync;
  80595. private static _PostExportAsync;
  80596. /**
  80597. * Exports the geometry of the scene to .glb file format asychronously
  80598. * @param scene Babylon scene with scene hierarchy information
  80599. * @param filePrefix File prefix to use when generating glb file
  80600. * @param options Exporter options
  80601. * @returns Returns an object with a .glb filename as key and data as value
  80602. */
  80603. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  80604. }
  80605. }
  80606. declare module BABYLON.GLTF2.Exporter {
  80607. /**
  80608. * @hidden
  80609. */
  80610. export class _GLTFUtilities {
  80611. /**
  80612. * Creates a buffer view based on the supplied arguments
  80613. * @param bufferIndex index value of the specified buffer
  80614. * @param byteOffset byte offset value
  80615. * @param byteLength byte length of the bufferView
  80616. * @param byteStride byte distance between conequential elements
  80617. * @param name name of the buffer view
  80618. * @returns bufferView for glTF
  80619. */
  80620. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  80621. /**
  80622. * Creates an accessor based on the supplied arguments
  80623. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  80624. * @param name The name of the accessor
  80625. * @param type The type of the accessor
  80626. * @param componentType The datatype of components in the attribute
  80627. * @param count The number of attributes referenced by this accessor
  80628. * @param byteOffset The offset relative to the start of the bufferView in bytes
  80629. * @param min Minimum value of each component in this attribute
  80630. * @param max Maximum value of each component in this attribute
  80631. * @returns accessor for glTF
  80632. */
  80633. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  80634. /**
  80635. * Calculates the minimum and maximum values of an array of position floats
  80636. * @param positions Positions array of a mesh
  80637. * @param vertexStart Starting vertex offset to calculate min and max values
  80638. * @param vertexCount Number of vertices to check for min and max values
  80639. * @returns min number array and max number array
  80640. */
  80641. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  80642. min: number[];
  80643. max: number[];
  80644. };
  80645. /**
  80646. * Converts a new right-handed Vector3
  80647. * @param vector vector3 array
  80648. * @returns right-handed Vector3
  80649. */
  80650. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  80651. /**
  80652. * Converts a Vector3 to right-handed
  80653. * @param vector Vector3 to convert to right-handed
  80654. */
  80655. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  80656. /**
  80657. * Converts a three element number array to right-handed
  80658. * @param vector number array to convert to right-handed
  80659. */
  80660. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  80661. /**
  80662. * Converts a new right-handed Vector3
  80663. * @param vector vector3 array
  80664. * @returns right-handed Vector3
  80665. */
  80666. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  80667. /**
  80668. * Converts a Vector3 to right-handed
  80669. * @param vector Vector3 to convert to right-handed
  80670. */
  80671. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  80672. /**
  80673. * Converts a three element number array to right-handed
  80674. * @param vector number array to convert to right-handed
  80675. */
  80676. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  80677. /**
  80678. * Converts a Vector4 to right-handed
  80679. * @param vector Vector4 to convert to right-handed
  80680. */
  80681. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  80682. /**
  80683. * Converts a Vector4 to right-handed
  80684. * @param vector Vector4 to convert to right-handed
  80685. */
  80686. static _GetRightHandedArray4FromRef(vector: number[]): void;
  80687. /**
  80688. * Converts a Quaternion to right-handed
  80689. * @param quaternion Source quaternion to convert to right-handed
  80690. */
  80691. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  80692. /**
  80693. * Converts a Quaternion to right-handed
  80694. * @param quaternion Source quaternion to convert to right-handed
  80695. */
  80696. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  80697. static _NormalizeTangentFromRef(tangent: Vector4): void;
  80698. }
  80699. }
  80700. declare module BABYLON.GLTF2.Exporter {
  80701. /**
  80702. * Converts Babylon Scene into glTF 2.0.
  80703. * @hidden
  80704. */
  80705. export class _Exporter {
  80706. /**
  80707. * Stores the glTF to export
  80708. */
  80709. _glTF: IGLTF;
  80710. /**
  80711. * Stores all generated buffer views, which represents views into the main glTF buffer data
  80712. */
  80713. _bufferViews: IBufferView[];
  80714. /**
  80715. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  80716. */
  80717. _accessors: IAccessor[];
  80718. /**
  80719. * Stores all the generated nodes, which contains transform and/or mesh information per node
  80720. */
  80721. _nodes: INode[];
  80722. /**
  80723. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  80724. */
  80725. private _scenes;
  80726. /**
  80727. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  80728. */
  80729. private _meshes;
  80730. /**
  80731. * Stores all the generated material information, which represents the appearance of each primitive
  80732. */
  80733. _materials: IMaterial[];
  80734. _materialMap: {
  80735. [materialID: number]: number;
  80736. };
  80737. /**
  80738. * Stores all the generated texture information, which is referenced by glTF materials
  80739. */
  80740. _textures: ITexture[];
  80741. /**
  80742. * Stores all the generated image information, which is referenced by glTF textures
  80743. */
  80744. _images: IImage[];
  80745. /**
  80746. * Stores all the texture samplers
  80747. */
  80748. _samplers: ISampler[];
  80749. /**
  80750. * Stores all the generated animation samplers, which is referenced by glTF animations
  80751. */
  80752. /**
  80753. * Stores the animations for glTF models
  80754. */
  80755. private _animations;
  80756. /**
  80757. * Stores the total amount of bytes stored in the glTF buffer
  80758. */
  80759. private _totalByteLength;
  80760. /**
  80761. * Stores a reference to the Babylon scene containing the source geometry and material information
  80762. */
  80763. _babylonScene: Scene;
  80764. /**
  80765. * Stores a map of the image data, where the key is the file name and the value
  80766. * is the image data
  80767. */
  80768. _imageData: {
  80769. [fileName: string]: {
  80770. data: Uint8Array;
  80771. mimeType: ImageMimeType;
  80772. };
  80773. };
  80774. /**
  80775. * Stores a map of the unique id of a node to its index in the node array
  80776. */
  80777. _nodeMap: {
  80778. [key: number]: number;
  80779. };
  80780. /**
  80781. * Specifies if the source Babylon scene was left handed, and needed conversion.
  80782. */
  80783. _convertToRightHandedSystem: boolean;
  80784. /**
  80785. * Specifies if a Babylon node should be converted to right-handed on export
  80786. */
  80787. _convertToRightHandedSystemMap: {
  80788. [nodeId: number]: boolean;
  80789. };
  80790. _includeCoordinateSystemConversionNodes: boolean;
  80791. /**
  80792. * Baked animation sample rate
  80793. */
  80794. private _animationSampleRate;
  80795. private _options;
  80796. private _localEngine;
  80797. _glTFMaterialExporter: _GLTFMaterialExporter;
  80798. private _extensions;
  80799. private static _ExtensionNames;
  80800. private static _ExtensionFactories;
  80801. private _applyExtension;
  80802. private _applyExtensions;
  80803. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  80804. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  80805. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80806. [key: number]: number;
  80807. }): Promise<Nullable<INode>>;
  80808. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  80809. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  80810. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80811. private _forEachExtensions;
  80812. private _extensionsOnExporting;
  80813. /**
  80814. * Load glTF serializer extensions
  80815. */
  80816. private _loadExtensions;
  80817. /**
  80818. * Creates a glTF Exporter instance, which can accept optional exporter options
  80819. * @param babylonScene Babylon scene object
  80820. * @param options Options to modify the behavior of the exporter
  80821. */
  80822. constructor(babylonScene: Scene, options?: IExportOptions);
  80823. dispose(): void;
  80824. /**
  80825. * Registers a glTF exporter extension
  80826. * @param name Name of the extension to export
  80827. * @param factory The factory function that creates the exporter extension
  80828. */
  80829. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  80830. /**
  80831. * Un-registers an exporter extension
  80832. * @param name The name fo the exporter extension
  80833. * @returns A boolean indicating whether the extension has been un-registered
  80834. */
  80835. static UnregisterExtension(name: string): boolean;
  80836. /**
  80837. * Lazy load a local engine
  80838. */
  80839. _getLocalEngine(): Engine;
  80840. private reorderIndicesBasedOnPrimitiveMode;
  80841. /**
  80842. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  80843. * clock-wise during export to glTF
  80844. * @param submesh BabylonJS submesh
  80845. * @param primitiveMode Primitive mode of the mesh
  80846. * @param sideOrientation the winding order of the submesh
  80847. * @param vertexBufferKind The type of vertex attribute
  80848. * @param meshAttributeArray The vertex attribute data
  80849. * @param byteOffset The offset to the binary data
  80850. * @param binaryWriter The binary data for the glTF file
  80851. * @param convertToRightHandedSystem Converts the values to right-handed
  80852. */
  80853. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  80854. /**
  80855. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  80856. * clock-wise during export to glTF
  80857. * @param submesh BabylonJS submesh
  80858. * @param primitiveMode Primitive mode of the mesh
  80859. * @param sideOrientation the winding order of the submesh
  80860. * @param vertexBufferKind The type of vertex attribute
  80861. * @param meshAttributeArray The vertex attribute data
  80862. * @param byteOffset The offset to the binary data
  80863. * @param binaryWriter The binary data for the glTF file
  80864. * @param convertToRightHandedSystem Converts the values to right-handed
  80865. */
  80866. private reorderTriangleFillMode;
  80867. /**
  80868. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  80869. * clock-wise during export to glTF
  80870. * @param submesh BabylonJS submesh
  80871. * @param primitiveMode Primitive mode of the mesh
  80872. * @param sideOrientation the winding order of the submesh
  80873. * @param vertexBufferKind The type of vertex attribute
  80874. * @param meshAttributeArray The vertex attribute data
  80875. * @param byteOffset The offset to the binary data
  80876. * @param binaryWriter The binary data for the glTF file
  80877. * @param convertToRightHandedSystem Converts the values to right-handed
  80878. */
  80879. private reorderTriangleStripDrawMode;
  80880. /**
  80881. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  80882. * clock-wise during export to glTF
  80883. * @param submesh BabylonJS submesh
  80884. * @param primitiveMode Primitive mode of the mesh
  80885. * @param sideOrientation the winding order of the submesh
  80886. * @param vertexBufferKind The type of vertex attribute
  80887. * @param meshAttributeArray The vertex attribute data
  80888. * @param byteOffset The offset to the binary data
  80889. * @param binaryWriter The binary data for the glTF file
  80890. * @param convertToRightHandedSystem Converts the values to right-handed
  80891. */
  80892. private reorderTriangleFanMode;
  80893. /**
  80894. * Writes the vertex attribute data to binary
  80895. * @param vertices The vertices to write to the binary writer
  80896. * @param byteOffset The offset into the binary writer to overwrite binary data
  80897. * @param vertexAttributeKind The vertex attribute type
  80898. * @param meshAttributeArray The vertex attribute data
  80899. * @param binaryWriter The writer containing the binary data
  80900. * @param convertToRightHandedSystem Converts the values to right-handed
  80901. */
  80902. private writeVertexAttributeData;
  80903. /**
  80904. * Writes mesh attribute data to a data buffer
  80905. * Returns the bytelength of the data
  80906. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  80907. * @param meshAttributeArray Array containing the attribute data
  80908. * @param binaryWriter The buffer to write the binary data to
  80909. * @param indices Used to specify the order of the vertex data
  80910. * @param convertToRightHandedSystem Converts the values to right-handed
  80911. */
  80912. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  80913. /**
  80914. * Generates glTF json data
  80915. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  80916. * @param glTFPrefix Text to use when prefixing a glTF file
  80917. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  80918. * @returns json data as string
  80919. */
  80920. private generateJSON;
  80921. /**
  80922. * Generates data for .gltf and .bin files based on the glTF prefix string
  80923. * @param glTFPrefix Text to use when prefixing a glTF file
  80924. * @param dispose Dispose the exporter
  80925. * @returns GLTFData with glTF file data
  80926. */
  80927. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80928. /**
  80929. * Creates a binary buffer for glTF
  80930. * @returns array buffer for binary data
  80931. */
  80932. private _generateBinaryAsync;
  80933. /**
  80934. * Pads the number to a multiple of 4
  80935. * @param num number to pad
  80936. * @returns padded number
  80937. */
  80938. private _getPadding;
  80939. /**
  80940. * @hidden
  80941. */
  80942. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  80943. /**
  80944. * Sets the TRS for each node
  80945. * @param node glTF Node for storing the transformation data
  80946. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  80947. * @param convertToRightHandedSystem Converts the values to right-handed
  80948. */
  80949. private setNodeTransformation;
  80950. private getVertexBufferFromMesh;
  80951. /**
  80952. * Creates a bufferview based on the vertices type for the Babylon mesh
  80953. * @param kind Indicates the type of vertices data
  80954. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  80955. * @param binaryWriter The buffer to write the bufferview data to
  80956. * @param convertToRightHandedSystem Converts the values to right-handed
  80957. */
  80958. private createBufferViewKind;
  80959. /**
  80960. * The primitive mode of the Babylon mesh
  80961. * @param babylonMesh The BabylonJS mesh
  80962. */
  80963. private getMeshPrimitiveMode;
  80964. /**
  80965. * Sets the primitive mode of the glTF mesh primitive
  80966. * @param meshPrimitive glTF mesh primitive
  80967. * @param primitiveMode The primitive mode
  80968. */
  80969. private setPrimitiveMode;
  80970. /**
  80971. * Sets the vertex attribute accessor based of the glTF mesh primitive
  80972. * @param meshPrimitive glTF mesh primitive
  80973. * @param attributeKind vertex attribute
  80974. * @returns boolean specifying if uv coordinates are present
  80975. */
  80976. private setAttributeKind;
  80977. /**
  80978. * Sets data for the primitive attributes of each submesh
  80979. * @param mesh glTF Mesh object to store the primitive attribute information
  80980. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  80981. * @param binaryWriter Buffer to write the attribute data to
  80982. * @param convertToRightHandedSystem Converts the values to right-handed
  80983. */
  80984. private setPrimitiveAttributesAsync;
  80985. /**
  80986. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  80987. * @param node The node to check
  80988. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  80989. */
  80990. private isBabylonCoordinateSystemConvertingNode;
  80991. /**
  80992. * Creates a glTF scene based on the array of meshes
  80993. * Returns the the total byte offset
  80994. * @param babylonScene Babylon scene to get the mesh data from
  80995. * @param binaryWriter Buffer to write binary data to
  80996. */
  80997. private createSceneAsync;
  80998. /**
  80999. * Creates a mapping of Node unique id to node index and handles animations
  81000. * @param babylonScene Babylon Scene
  81001. * @param nodes Babylon transform nodes
  81002. * @param binaryWriter Buffer to write binary data to
  81003. * @returns Node mapping of unique id to index
  81004. */
  81005. private createNodeMapAndAnimationsAsync;
  81006. /**
  81007. * Creates a glTF node from a Babylon mesh
  81008. * @param babylonMesh Source Babylon mesh
  81009. * @param binaryWriter Buffer for storing geometry data
  81010. * @param convertToRightHandedSystem Converts the values to right-handed
  81011. * @param nodeMap Node mapping of unique id to glTF node index
  81012. * @returns glTF node
  81013. */
  81014. private createNodeAsync;
  81015. }
  81016. /**
  81017. * @hidden
  81018. *
  81019. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  81020. */
  81021. export class _BinaryWriter {
  81022. /**
  81023. * Array buffer which stores all binary data
  81024. */
  81025. private _arrayBuffer;
  81026. /**
  81027. * View of the array buffer
  81028. */
  81029. private _dataView;
  81030. /**
  81031. * byte offset of data in array buffer
  81032. */
  81033. private _byteOffset;
  81034. /**
  81035. * Initialize binary writer with an initial byte length
  81036. * @param byteLength Initial byte length of the array buffer
  81037. */
  81038. constructor(byteLength: number);
  81039. /**
  81040. * Resize the array buffer to the specified byte length
  81041. * @param byteLength
  81042. */
  81043. private resizeBuffer;
  81044. /**
  81045. * Get an array buffer with the length of the byte offset
  81046. * @returns ArrayBuffer resized to the byte offset
  81047. */
  81048. getArrayBuffer(): ArrayBuffer;
  81049. /**
  81050. * Get the byte offset of the array buffer
  81051. * @returns byte offset
  81052. */
  81053. getByteOffset(): number;
  81054. /**
  81055. * Stores an UInt8 in the array buffer
  81056. * @param entry
  81057. * @param byteOffset If defined, specifies where to set the value as an offset.
  81058. */
  81059. setUInt8(entry: number, byteOffset?: number): void;
  81060. /**
  81061. * Gets an UInt32 in the array buffer
  81062. * @param entry
  81063. * @param byteOffset If defined, specifies where to set the value as an offset.
  81064. */
  81065. getUInt32(byteOffset: number): number;
  81066. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81067. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81068. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81069. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81070. /**
  81071. * Stores a Float32 in the array buffer
  81072. * @param entry
  81073. */
  81074. setFloat32(entry: number, byteOffset?: number): void;
  81075. /**
  81076. * Stores an UInt32 in the array buffer
  81077. * @param entry
  81078. * @param byteOffset If defined, specifies where to set the value as an offset.
  81079. */
  81080. setUInt32(entry: number, byteOffset?: number): void;
  81081. }
  81082. }
  81083. declare module BABYLON.GLTF2.Exporter {
  81084. /**
  81085. * @hidden
  81086. * Interface to store animation data.
  81087. */
  81088. export interface _IAnimationData {
  81089. /**
  81090. * Keyframe data.
  81091. */
  81092. inputs: number[];
  81093. /**
  81094. * Value data.
  81095. */
  81096. outputs: number[][];
  81097. /**
  81098. * Animation interpolation data.
  81099. */
  81100. samplerInterpolation: AnimationSamplerInterpolation;
  81101. /**
  81102. * Minimum keyframe value.
  81103. */
  81104. inputsMin: number;
  81105. /**
  81106. * Maximum keyframe value.
  81107. */
  81108. inputsMax: number;
  81109. }
  81110. /**
  81111. * @hidden
  81112. */
  81113. export interface _IAnimationInfo {
  81114. /**
  81115. * The target channel for the animation
  81116. */
  81117. animationChannelTargetPath: AnimationChannelTargetPath;
  81118. /**
  81119. * The glTF accessor type for the data.
  81120. */
  81121. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  81122. /**
  81123. * Specifies if quaternions should be used.
  81124. */
  81125. useQuaternion: boolean;
  81126. }
  81127. /**
  81128. * @hidden
  81129. * Utility class for generating glTF animation data from BabylonJS.
  81130. */
  81131. export class _GLTFAnimation {
  81132. /**
  81133. * @ignore
  81134. *
  81135. * Creates glTF channel animation from BabylonJS animation.
  81136. * @param babylonTransformNode - BabylonJS mesh.
  81137. * @param animation - animation.
  81138. * @param animationChannelTargetPath - The target animation channel.
  81139. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81140. * @param useQuaternion - Specifies if quaternions are used.
  81141. * @returns nullable IAnimationData
  81142. */
  81143. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81144. private static _DeduceAnimationInfo;
  81145. /**
  81146. * @ignore
  81147. * Create node animations from the transform node animations
  81148. * @param babylonNode
  81149. * @param runtimeGLTFAnimation
  81150. * @param idleGLTFAnimations
  81151. * @param nodeMap
  81152. * @param nodes
  81153. * @param binaryWriter
  81154. * @param bufferViews
  81155. * @param accessors
  81156. * @param convertToRightHandedSystem
  81157. * @param animationSampleRate
  81158. */
  81159. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81160. [key: number]: number;
  81161. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81162. /**
  81163. * @ignore
  81164. * Create node animations from the animation groups
  81165. * @param babylonScene
  81166. * @param glTFAnimations
  81167. * @param nodeMap
  81168. * @param nodes
  81169. * @param binaryWriter
  81170. * @param bufferViews
  81171. * @param accessors
  81172. * @param convertToRightHandedSystemMap
  81173. * @param animationSampleRate
  81174. */
  81175. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81176. [key: number]: number;
  81177. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81178. [nodeId: number]: boolean;
  81179. }, animationSampleRate: number): void;
  81180. private static AddAnimation;
  81181. /**
  81182. * Create a baked animation
  81183. * @param babylonTransformNode BabylonJS mesh
  81184. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81185. * @param animationChannelTargetPath animation target channel
  81186. * @param minFrame minimum animation frame
  81187. * @param maxFrame maximum animation frame
  81188. * @param fps frames per second of the animation
  81189. * @param inputs input key frames of the animation
  81190. * @param outputs output key frame data of the animation
  81191. * @param convertToRightHandedSystem converts the values to right-handed
  81192. * @param useQuaternion specifies if quaternions should be used
  81193. */
  81194. private static _CreateBakedAnimation;
  81195. private static _ConvertFactorToVector3OrQuaternion;
  81196. private static _SetInterpolatedValue;
  81197. /**
  81198. * Creates linear animation from the animation key frames
  81199. * @param babylonTransformNode BabylonJS mesh
  81200. * @param animation BabylonJS animation
  81201. * @param animationChannelTargetPath The target animation channel
  81202. * @param frameDelta The difference between the last and first frame of the animation
  81203. * @param inputs Array to store the key frame times
  81204. * @param outputs Array to store the key frame data
  81205. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81206. * @param useQuaternion Specifies if quaternions are used in the animation
  81207. */
  81208. private static _CreateLinearOrStepAnimation;
  81209. /**
  81210. * Creates cubic spline animation from the animation key frames
  81211. * @param babylonTransformNode BabylonJS mesh
  81212. * @param animation BabylonJS animation
  81213. * @param animationChannelTargetPath The target animation channel
  81214. * @param frameDelta The difference between the last and first frame of the animation
  81215. * @param inputs Array to store the key frame times
  81216. * @param outputs Array to store the key frame data
  81217. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81218. * @param useQuaternion Specifies if quaternions are used in the animation
  81219. */
  81220. private static _CreateCubicSplineAnimation;
  81221. private static _GetBasePositionRotationOrScale;
  81222. /**
  81223. * Adds a key frame value
  81224. * @param keyFrame
  81225. * @param animation
  81226. * @param outputs
  81227. * @param animationChannelTargetPath
  81228. * @param basePositionRotationOrScale
  81229. * @param convertToRightHandedSystem
  81230. * @param useQuaternion
  81231. */
  81232. private static _AddKeyframeValue;
  81233. /**
  81234. * Determine the interpolation based on the key frames
  81235. * @param keyFrames
  81236. * @param animationChannelTargetPath
  81237. * @param useQuaternion
  81238. */
  81239. private static _DeduceInterpolation;
  81240. /**
  81241. * Adds an input tangent or output tangent to the output data
  81242. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81243. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81244. * @param outputs The animation data by keyframe
  81245. * @param animationChannelTargetPath The target animation channel
  81246. * @param interpolation The interpolation type
  81247. * @param keyFrame The key frame with the animation data
  81248. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81249. * @param useQuaternion Specifies if quaternions are used
  81250. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81251. */
  81252. private static AddSplineTangent;
  81253. /**
  81254. * Get the minimum and maximum key frames' frame values
  81255. * @param keyFrames animation key frames
  81256. * @returns the minimum and maximum key frame value
  81257. */
  81258. private static calculateMinMaxKeyFrames;
  81259. }
  81260. }
  81261. declare module BABYLON.GLTF2.Exporter {
  81262. /** @hidden */
  81263. export var textureTransformPixelShader: {
  81264. name: string;
  81265. shader: string;
  81266. };
  81267. }
  81268. declare module BABYLON.GLTF2.Exporter.Extensions {
  81269. /**
  81270. * @hidden
  81271. */
  81272. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81273. private _recordedTextures;
  81274. /** Name of this extension */
  81275. readonly name: string;
  81276. /** Defines whether this extension is enabled */
  81277. enabled: boolean;
  81278. /** Defines whether this extension is required */
  81279. required: boolean;
  81280. /** Reference to the glTF exporter */
  81281. private _wasUsed;
  81282. constructor(exporter: _Exporter);
  81283. dispose(): void;
  81284. /** @hidden */
  81285. get wasUsed(): boolean;
  81286. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81287. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81288. /**
  81289. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81290. * @param babylonTexture
  81291. * @param offset
  81292. * @param rotation
  81293. * @param scale
  81294. * @param scene
  81295. */
  81296. private _textureTransformTextureAsync;
  81297. }
  81298. }
  81299. declare module BABYLON.GLTF2.Exporter.Extensions {
  81300. /**
  81301. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81302. */
  81303. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81304. /** The name of this extension. */
  81305. readonly name: string;
  81306. /** Defines whether this extension is enabled. */
  81307. enabled: boolean;
  81308. /** Defines whether this extension is required */
  81309. required: boolean;
  81310. /** Reference to the glTF exporter */
  81311. private _exporter;
  81312. private _lights;
  81313. /** @hidden */
  81314. constructor(exporter: _Exporter);
  81315. /** @hidden */
  81316. dispose(): void;
  81317. /** @hidden */
  81318. get wasUsed(): boolean;
  81319. /** @hidden */
  81320. onExporting(): void;
  81321. /**
  81322. * Define this method to modify the default behavior when exporting a node
  81323. * @param context The context when exporting the node
  81324. * @param node glTF node
  81325. * @param babylonNode BabylonJS node
  81326. * @param nodeMap Node mapping of unique id to glTF node index
  81327. * @returns nullable INode promise
  81328. */
  81329. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81330. [key: number]: number;
  81331. }): Promise<Nullable<INode>>;
  81332. }
  81333. }
  81334. declare module BABYLON.GLTF2.Exporter.Extensions {
  81335. /**
  81336. * @hidden
  81337. */
  81338. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81339. /** Name of this extension */
  81340. readonly name: string;
  81341. /** Defines whether this extension is enabled */
  81342. enabled: boolean;
  81343. /** Defines whether this extension is required */
  81344. required: boolean;
  81345. /** Reference to the glTF exporter */
  81346. private _textureInfos;
  81347. private _exportedTextures;
  81348. private _wasUsed;
  81349. constructor(exporter: _Exporter);
  81350. dispose(): void;
  81351. /** @hidden */
  81352. get wasUsed(): boolean;
  81353. private _getTextureIndex;
  81354. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81355. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81356. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81357. }
  81358. }
  81359. declare module BABYLON {
  81360. /**
  81361. * Class for generating STL data from a Babylon scene.
  81362. */
  81363. export class STLExport {
  81364. /**
  81365. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81366. * @param meshes list defines the mesh to serialize
  81367. * @param download triggers the automatic download of the file.
  81368. * @param fileName changes the downloads fileName.
  81369. * @param binary changes the STL to a binary type.
  81370. * @param isLittleEndian toggle for binary type exporter.
  81371. * @returns the STL as UTF8 string
  81372. */
  81373. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81374. }
  81375. }
  81376. declare module "babylonjs-gltf2interface" {
  81377. export = BABYLON.GLTF2;
  81378. }
  81379. /**
  81380. * Module for glTF 2.0 Interface
  81381. */
  81382. declare module BABYLON.GLTF2 {
  81383. /**
  81384. * The datatype of the components in the attribute
  81385. */
  81386. const enum AccessorComponentType {
  81387. /**
  81388. * Byte
  81389. */
  81390. BYTE = 5120,
  81391. /**
  81392. * Unsigned Byte
  81393. */
  81394. UNSIGNED_BYTE = 5121,
  81395. /**
  81396. * Short
  81397. */
  81398. SHORT = 5122,
  81399. /**
  81400. * Unsigned Short
  81401. */
  81402. UNSIGNED_SHORT = 5123,
  81403. /**
  81404. * Unsigned Int
  81405. */
  81406. UNSIGNED_INT = 5125,
  81407. /**
  81408. * Float
  81409. */
  81410. FLOAT = 5126,
  81411. }
  81412. /**
  81413. * Specifies if the attirbute is a scalar, vector, or matrix
  81414. */
  81415. const enum AccessorType {
  81416. /**
  81417. * Scalar
  81418. */
  81419. SCALAR = "SCALAR",
  81420. /**
  81421. * Vector2
  81422. */
  81423. VEC2 = "VEC2",
  81424. /**
  81425. * Vector3
  81426. */
  81427. VEC3 = "VEC3",
  81428. /**
  81429. * Vector4
  81430. */
  81431. VEC4 = "VEC4",
  81432. /**
  81433. * Matrix2x2
  81434. */
  81435. MAT2 = "MAT2",
  81436. /**
  81437. * Matrix3x3
  81438. */
  81439. MAT3 = "MAT3",
  81440. /**
  81441. * Matrix4x4
  81442. */
  81443. MAT4 = "MAT4",
  81444. }
  81445. /**
  81446. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81447. */
  81448. const enum AnimationChannelTargetPath {
  81449. /**
  81450. * Translation
  81451. */
  81452. TRANSLATION = "translation",
  81453. /**
  81454. * Rotation
  81455. */
  81456. ROTATION = "rotation",
  81457. /**
  81458. * Scale
  81459. */
  81460. SCALE = "scale",
  81461. /**
  81462. * Weights
  81463. */
  81464. WEIGHTS = "weights",
  81465. }
  81466. /**
  81467. * Interpolation algorithm
  81468. */
  81469. const enum AnimationSamplerInterpolation {
  81470. /**
  81471. * The animated values are linearly interpolated between keyframes
  81472. */
  81473. LINEAR = "LINEAR",
  81474. /**
  81475. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  81476. */
  81477. STEP = "STEP",
  81478. /**
  81479. * The animation's interpolation is computed using a cubic spline with specified tangents
  81480. */
  81481. CUBICSPLINE = "CUBICSPLINE",
  81482. }
  81483. /**
  81484. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81485. */
  81486. const enum CameraType {
  81487. /**
  81488. * A perspective camera containing properties to create a perspective projection matrix
  81489. */
  81490. PERSPECTIVE = "perspective",
  81491. /**
  81492. * An orthographic camera containing properties to create an orthographic projection matrix
  81493. */
  81494. ORTHOGRAPHIC = "orthographic",
  81495. }
  81496. /**
  81497. * The mime-type of the image
  81498. */
  81499. const enum ImageMimeType {
  81500. /**
  81501. * JPEG Mime-type
  81502. */
  81503. JPEG = "image/jpeg",
  81504. /**
  81505. * PNG Mime-type
  81506. */
  81507. PNG = "image/png",
  81508. }
  81509. /**
  81510. * The alpha rendering mode of the material
  81511. */
  81512. const enum MaterialAlphaMode {
  81513. /**
  81514. * The alpha value is ignored and the rendered output is fully opaque
  81515. */
  81516. OPAQUE = "OPAQUE",
  81517. /**
  81518. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  81519. */
  81520. MASK = "MASK",
  81521. /**
  81522. * 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)
  81523. */
  81524. BLEND = "BLEND",
  81525. }
  81526. /**
  81527. * The type of the primitives to render
  81528. */
  81529. const enum MeshPrimitiveMode {
  81530. /**
  81531. * Points
  81532. */
  81533. POINTS = 0,
  81534. /**
  81535. * Lines
  81536. */
  81537. LINES = 1,
  81538. /**
  81539. * Line Loop
  81540. */
  81541. LINE_LOOP = 2,
  81542. /**
  81543. * Line Strip
  81544. */
  81545. LINE_STRIP = 3,
  81546. /**
  81547. * Triangles
  81548. */
  81549. TRIANGLES = 4,
  81550. /**
  81551. * Triangle Strip
  81552. */
  81553. TRIANGLE_STRIP = 5,
  81554. /**
  81555. * Triangle Fan
  81556. */
  81557. TRIANGLE_FAN = 6,
  81558. }
  81559. /**
  81560. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  81561. */
  81562. const enum TextureMagFilter {
  81563. /**
  81564. * Nearest
  81565. */
  81566. NEAREST = 9728,
  81567. /**
  81568. * Linear
  81569. */
  81570. LINEAR = 9729,
  81571. }
  81572. /**
  81573. * Minification filter. All valid values correspond to WebGL enums
  81574. */
  81575. const enum TextureMinFilter {
  81576. /**
  81577. * Nearest
  81578. */
  81579. NEAREST = 9728,
  81580. /**
  81581. * Linear
  81582. */
  81583. LINEAR = 9729,
  81584. /**
  81585. * Nearest Mip-Map Nearest
  81586. */
  81587. NEAREST_MIPMAP_NEAREST = 9984,
  81588. /**
  81589. * Linear Mipmap Nearest
  81590. */
  81591. LINEAR_MIPMAP_NEAREST = 9985,
  81592. /**
  81593. * Nearest Mipmap Linear
  81594. */
  81595. NEAREST_MIPMAP_LINEAR = 9986,
  81596. /**
  81597. * Linear Mipmap Linear
  81598. */
  81599. LINEAR_MIPMAP_LINEAR = 9987,
  81600. }
  81601. /**
  81602. * S (U) wrapping mode. All valid values correspond to WebGL enums
  81603. */
  81604. const enum TextureWrapMode {
  81605. /**
  81606. * Clamp to Edge
  81607. */
  81608. CLAMP_TO_EDGE = 33071,
  81609. /**
  81610. * Mirrored Repeat
  81611. */
  81612. MIRRORED_REPEAT = 33648,
  81613. /**
  81614. * Repeat
  81615. */
  81616. REPEAT = 10497,
  81617. }
  81618. /**
  81619. * glTF Property
  81620. */
  81621. interface IProperty {
  81622. /**
  81623. * Dictionary object with extension-specific objects
  81624. */
  81625. extensions?: {
  81626. [key: string]: any;
  81627. };
  81628. /**
  81629. * Application-Specific data
  81630. */
  81631. extras?: any;
  81632. }
  81633. /**
  81634. * glTF Child of Root Property
  81635. */
  81636. interface IChildRootProperty extends IProperty {
  81637. /**
  81638. * The user-defined name of this object
  81639. */
  81640. name?: string;
  81641. }
  81642. /**
  81643. * Indices of those attributes that deviate from their initialization value
  81644. */
  81645. interface IAccessorSparseIndices extends IProperty {
  81646. /**
  81647. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81648. */
  81649. bufferView: number;
  81650. /**
  81651. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81652. */
  81653. byteOffset?: number;
  81654. /**
  81655. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  81656. */
  81657. componentType: AccessorComponentType;
  81658. }
  81659. /**
  81660. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  81661. */
  81662. interface IAccessorSparseValues extends IProperty {
  81663. /**
  81664. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  81665. */
  81666. bufferView: number;
  81667. /**
  81668. * The offset relative to the start of the bufferView in bytes. Must be aligned
  81669. */
  81670. byteOffset?: number;
  81671. }
  81672. /**
  81673. * Sparse storage of attributes that deviate from their initialization value
  81674. */
  81675. interface IAccessorSparse extends IProperty {
  81676. /**
  81677. * The number of attributes encoded in this sparse accessor
  81678. */
  81679. count: number;
  81680. /**
  81681. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  81682. */
  81683. indices: IAccessorSparseIndices;
  81684. /**
  81685. * 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
  81686. */
  81687. values: IAccessorSparseValues;
  81688. }
  81689. /**
  81690. * 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
  81691. */
  81692. interface IAccessor extends IChildRootProperty {
  81693. /**
  81694. * The index of the bufferview
  81695. */
  81696. bufferView?: number;
  81697. /**
  81698. * The offset relative to the start of the bufferView in bytes
  81699. */
  81700. byteOffset?: number;
  81701. /**
  81702. * The datatype of components in the attribute
  81703. */
  81704. componentType: AccessorComponentType;
  81705. /**
  81706. * Specifies whether integer data values should be normalized
  81707. */
  81708. normalized?: boolean;
  81709. /**
  81710. * The number of attributes referenced by this accessor
  81711. */
  81712. count: number;
  81713. /**
  81714. * Specifies if the attribute is a scalar, vector, or matrix
  81715. */
  81716. type: AccessorType;
  81717. /**
  81718. * Maximum value of each component in this attribute
  81719. */
  81720. max?: number[];
  81721. /**
  81722. * Minimum value of each component in this attribute
  81723. */
  81724. min?: number[];
  81725. /**
  81726. * Sparse storage of attributes that deviate from their initialization value
  81727. */
  81728. sparse?: IAccessorSparse;
  81729. }
  81730. /**
  81731. * Targets an animation's sampler at a node's property
  81732. */
  81733. interface IAnimationChannel extends IProperty {
  81734. /**
  81735. * The index of a sampler in this animation used to compute the value for the target
  81736. */
  81737. sampler: number;
  81738. /**
  81739. * The index of the node and TRS property to target
  81740. */
  81741. target: IAnimationChannelTarget;
  81742. }
  81743. /**
  81744. * The index of the node and TRS property that an animation channel targets
  81745. */
  81746. interface IAnimationChannelTarget extends IProperty {
  81747. /**
  81748. * The index of the node to target
  81749. */
  81750. node: number;
  81751. /**
  81752. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  81753. */
  81754. path: AnimationChannelTargetPath;
  81755. }
  81756. /**
  81757. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81758. */
  81759. interface IAnimationSampler extends IProperty {
  81760. /**
  81761. * The index of an accessor containing keyframe input values, e.g., time
  81762. */
  81763. input: number;
  81764. /**
  81765. * Interpolation algorithm
  81766. */
  81767. interpolation?: AnimationSamplerInterpolation;
  81768. /**
  81769. * The index of an accessor, containing keyframe output values
  81770. */
  81771. output: number;
  81772. }
  81773. /**
  81774. * A keyframe animation
  81775. */
  81776. interface IAnimation extends IChildRootProperty {
  81777. /**
  81778. * An array of channels, each of which targets an animation's sampler at a node's property
  81779. */
  81780. channels: IAnimationChannel[];
  81781. /**
  81782. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  81783. */
  81784. samplers: IAnimationSampler[];
  81785. }
  81786. /**
  81787. * Metadata about the glTF asset
  81788. */
  81789. interface IAsset extends IChildRootProperty {
  81790. /**
  81791. * A copyright message suitable for display to credit the content creator
  81792. */
  81793. copyright?: string;
  81794. /**
  81795. * Tool that generated this glTF model. Useful for debugging
  81796. */
  81797. generator?: string;
  81798. /**
  81799. * The glTF version that this asset targets
  81800. */
  81801. version: string;
  81802. /**
  81803. * The minimum glTF version that this asset targets
  81804. */
  81805. minVersion?: string;
  81806. }
  81807. /**
  81808. * A buffer points to binary geometry, animation, or skins
  81809. */
  81810. interface IBuffer extends IChildRootProperty {
  81811. /**
  81812. * 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
  81813. */
  81814. uri?: string;
  81815. /**
  81816. * The length of the buffer in bytes
  81817. */
  81818. byteLength: number;
  81819. }
  81820. /**
  81821. * A view into a buffer generally representing a subset of the buffer
  81822. */
  81823. interface IBufferView extends IChildRootProperty {
  81824. /**
  81825. * The index of the buffer
  81826. */
  81827. buffer: number;
  81828. /**
  81829. * The offset into the buffer in bytes
  81830. */
  81831. byteOffset?: number;
  81832. /**
  81833. * The lenth of the bufferView in bytes
  81834. */
  81835. byteLength: number;
  81836. /**
  81837. * The stride, in bytes
  81838. */
  81839. byteStride?: number;
  81840. }
  81841. /**
  81842. * An orthographic camera containing properties to create an orthographic projection matrix
  81843. */
  81844. interface ICameraOrthographic extends IProperty {
  81845. /**
  81846. * The floating-point horizontal magnification of the view. Must not be zero
  81847. */
  81848. xmag: number;
  81849. /**
  81850. * The floating-point vertical magnification of the view. Must not be zero
  81851. */
  81852. ymag: number;
  81853. /**
  81854. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  81855. */
  81856. zfar: number;
  81857. /**
  81858. * The floating-point distance to the near clipping plane
  81859. */
  81860. znear: number;
  81861. }
  81862. /**
  81863. * A perspective camera containing properties to create a perspective projection matrix
  81864. */
  81865. interface ICameraPerspective extends IProperty {
  81866. /**
  81867. * The floating-point aspect ratio of the field of view
  81868. */
  81869. aspectRatio?: number;
  81870. /**
  81871. * The floating-point vertical field of view in radians
  81872. */
  81873. yfov: number;
  81874. /**
  81875. * The floating-point distance to the far clipping plane
  81876. */
  81877. zfar?: number;
  81878. /**
  81879. * The floating-point distance to the near clipping plane
  81880. */
  81881. znear: number;
  81882. }
  81883. /**
  81884. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  81885. */
  81886. interface ICamera extends IChildRootProperty {
  81887. /**
  81888. * An orthographic camera containing properties to create an orthographic projection matrix
  81889. */
  81890. orthographic?: ICameraOrthographic;
  81891. /**
  81892. * A perspective camera containing properties to create a perspective projection matrix
  81893. */
  81894. perspective?: ICameraPerspective;
  81895. /**
  81896. * Specifies if the camera uses a perspective or orthographic projection
  81897. */
  81898. type: CameraType;
  81899. }
  81900. /**
  81901. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  81902. */
  81903. interface IImage extends IChildRootProperty {
  81904. /**
  81905. * 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
  81906. */
  81907. uri?: string;
  81908. /**
  81909. * The image's MIME type
  81910. */
  81911. mimeType?: ImageMimeType;
  81912. /**
  81913. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  81914. */
  81915. bufferView?: number;
  81916. }
  81917. /**
  81918. * Material Normal Texture Info
  81919. */
  81920. interface IMaterialNormalTextureInfo extends ITextureInfo {
  81921. /**
  81922. * The scalar multiplier applied to each normal vector of the normal texture
  81923. */
  81924. scale?: number;
  81925. }
  81926. /**
  81927. * Material Occlusion Texture Info
  81928. */
  81929. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  81930. /**
  81931. * A scalar multiplier controlling the amount of occlusion applied
  81932. */
  81933. strength?: number;
  81934. }
  81935. /**
  81936. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  81937. */
  81938. interface IMaterialPbrMetallicRoughness {
  81939. /**
  81940. * The material's base color factor
  81941. */
  81942. baseColorFactor?: number[];
  81943. /**
  81944. * The base color texture
  81945. */
  81946. baseColorTexture?: ITextureInfo;
  81947. /**
  81948. * The metalness of the material
  81949. */
  81950. metallicFactor?: number;
  81951. /**
  81952. * The roughness of the material
  81953. */
  81954. roughnessFactor?: number;
  81955. /**
  81956. * The metallic-roughness texture
  81957. */
  81958. metallicRoughnessTexture?: ITextureInfo;
  81959. }
  81960. /**
  81961. * The material appearance of a primitive
  81962. */
  81963. interface IMaterial extends IChildRootProperty {
  81964. /**
  81965. * 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
  81966. */
  81967. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81968. /**
  81969. * The normal map texture
  81970. */
  81971. normalTexture?: IMaterialNormalTextureInfo;
  81972. /**
  81973. * The occlusion map texture
  81974. */
  81975. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81976. /**
  81977. * The emissive map texture
  81978. */
  81979. emissiveTexture?: ITextureInfo;
  81980. /**
  81981. * 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
  81982. */
  81983. emissiveFactor?: number[];
  81984. /**
  81985. * The alpha rendering mode of the material
  81986. */
  81987. alphaMode?: MaterialAlphaMode;
  81988. /**
  81989. * The alpha cutoff value of the material
  81990. */
  81991. alphaCutoff?: number;
  81992. /**
  81993. * Specifies whether the material is double sided
  81994. */
  81995. doubleSided?: boolean;
  81996. }
  81997. /**
  81998. * Geometry to be rendered with the given material
  81999. */
  82000. interface IMeshPrimitive extends IProperty {
  82001. /**
  82002. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  82003. */
  82004. attributes: {
  82005. [name: string]: number;
  82006. };
  82007. /**
  82008. * The index of the accessor that contains the indices
  82009. */
  82010. indices?: number;
  82011. /**
  82012. * The index of the material to apply to this primitive when rendering
  82013. */
  82014. material?: number;
  82015. /**
  82016. * The type of primitives to render. All valid values correspond to WebGL enums
  82017. */
  82018. mode?: MeshPrimitiveMode;
  82019. /**
  82020. * 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
  82021. */
  82022. targets?: {
  82023. [name: string]: number;
  82024. }[];
  82025. }
  82026. /**
  82027. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  82028. */
  82029. interface IMesh extends IChildRootProperty {
  82030. /**
  82031. * An array of primitives, each defining geometry to be rendered with a material
  82032. */
  82033. primitives: IMeshPrimitive[];
  82034. /**
  82035. * Array of weights to be applied to the Morph Targets
  82036. */
  82037. weights?: number[];
  82038. }
  82039. /**
  82040. * A node in the node hierarchy
  82041. */
  82042. interface INode extends IChildRootProperty {
  82043. /**
  82044. * The index of the camera referenced by this node
  82045. */
  82046. camera?: number;
  82047. /**
  82048. * The indices of this node's children
  82049. */
  82050. children?: number[];
  82051. /**
  82052. * The index of the skin referenced by this node
  82053. */
  82054. skin?: number;
  82055. /**
  82056. * A floating-point 4x4 transformation matrix stored in column-major order
  82057. */
  82058. matrix?: number[];
  82059. /**
  82060. * The index of the mesh in this node
  82061. */
  82062. mesh?: number;
  82063. /**
  82064. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  82065. */
  82066. rotation?: number[];
  82067. /**
  82068. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  82069. */
  82070. scale?: number[];
  82071. /**
  82072. * The node's translation along the x, y, and z axes
  82073. */
  82074. translation?: number[];
  82075. /**
  82076. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  82077. */
  82078. weights?: number[];
  82079. }
  82080. /**
  82081. * Texture sampler properties for filtering and wrapping modes
  82082. */
  82083. interface ISampler extends IChildRootProperty {
  82084. /**
  82085. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82086. */
  82087. magFilter?: TextureMagFilter;
  82088. /**
  82089. * Minification filter. All valid values correspond to WebGL enums
  82090. */
  82091. minFilter?: TextureMinFilter;
  82092. /**
  82093. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82094. */
  82095. wrapS?: TextureWrapMode;
  82096. /**
  82097. * T (V) wrapping mode. All valid values correspond to WebGL enums
  82098. */
  82099. wrapT?: TextureWrapMode;
  82100. }
  82101. /**
  82102. * The root nodes of a scene
  82103. */
  82104. interface IScene extends IChildRootProperty {
  82105. /**
  82106. * The indices of each root node
  82107. */
  82108. nodes: number[];
  82109. }
  82110. /**
  82111. * Joints and matrices defining a skin
  82112. */
  82113. interface ISkin extends IChildRootProperty {
  82114. /**
  82115. * 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
  82116. */
  82117. inverseBindMatrices?: number;
  82118. /**
  82119. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  82120. */
  82121. skeleton?: number;
  82122. /**
  82123. * 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)
  82124. */
  82125. joints: number[];
  82126. }
  82127. /**
  82128. * A texture and its sampler
  82129. */
  82130. interface ITexture extends IChildRootProperty {
  82131. /**
  82132. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82133. */
  82134. sampler?: number;
  82135. /**
  82136. * The index of the image used by this texture
  82137. */
  82138. source: number;
  82139. }
  82140. /**
  82141. * Reference to a texture
  82142. */
  82143. interface ITextureInfo extends IProperty {
  82144. /**
  82145. * The index of the texture
  82146. */
  82147. index: number;
  82148. /**
  82149. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82150. */
  82151. texCoord?: number;
  82152. }
  82153. /**
  82154. * The root object for a glTF asset
  82155. */
  82156. interface IGLTF extends IProperty {
  82157. /**
  82158. * An array of accessors. An accessor is a typed view into a bufferView
  82159. */
  82160. accessors?: IAccessor[];
  82161. /**
  82162. * An array of keyframe animations
  82163. */
  82164. animations?: IAnimation[];
  82165. /**
  82166. * Metadata about the glTF asset
  82167. */
  82168. asset: IAsset;
  82169. /**
  82170. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82171. */
  82172. buffers?: IBuffer[];
  82173. /**
  82174. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82175. */
  82176. bufferViews?: IBufferView[];
  82177. /**
  82178. * An array of cameras
  82179. */
  82180. cameras?: ICamera[];
  82181. /**
  82182. * Names of glTF extensions used somewhere in this asset
  82183. */
  82184. extensionsUsed?: string[];
  82185. /**
  82186. * Names of glTF extensions required to properly load this asset
  82187. */
  82188. extensionsRequired?: string[];
  82189. /**
  82190. * An array of images. An image defines data used to create a texture
  82191. */
  82192. images?: IImage[];
  82193. /**
  82194. * An array of materials. A material defines the appearance of a primitive
  82195. */
  82196. materials?: IMaterial[];
  82197. /**
  82198. * An array of meshes. A mesh is a set of primitives to be rendered
  82199. */
  82200. meshes?: IMesh[];
  82201. /**
  82202. * An array of nodes
  82203. */
  82204. nodes?: INode[];
  82205. /**
  82206. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82207. */
  82208. samplers?: ISampler[];
  82209. /**
  82210. * The index of the default scene
  82211. */
  82212. scene?: number;
  82213. /**
  82214. * An array of scenes
  82215. */
  82216. scenes?: IScene[];
  82217. /**
  82218. * An array of skins. A skin is defined by joints and matrices
  82219. */
  82220. skins?: ISkin[];
  82221. /**
  82222. * An array of textures
  82223. */
  82224. textures?: ITexture[];
  82225. }
  82226. /**
  82227. * The glTF validation results
  82228. * @ignore
  82229. */
  82230. interface IGLTFValidationResults {
  82231. info: {
  82232. generator: string;
  82233. hasAnimations: boolean;
  82234. hasDefaultScene: boolean;
  82235. hasMaterials: boolean;
  82236. hasMorphTargets: boolean;
  82237. hasSkins: boolean;
  82238. hasTextures: boolean;
  82239. maxAttributesUsed: number;
  82240. primitivesCount: number
  82241. };
  82242. issues: {
  82243. messages: Array<string>;
  82244. numErrors: number;
  82245. numHints: number;
  82246. numInfos: number;
  82247. numWarnings: number;
  82248. truncated: boolean
  82249. };
  82250. mimeType: string;
  82251. uri: string;
  82252. validatedAt: string;
  82253. validatorVersion: string;
  82254. }
  82255. /**
  82256. * The glTF validation options
  82257. */
  82258. interface IGLTFValidationOptions {
  82259. /** Uri to use */
  82260. uri?: string;
  82261. /** Function used to load external resources */
  82262. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82263. /** Boolean indicating that we need to validate accessor data */
  82264. validateAccessorData?: boolean;
  82265. /** max number of issues allowed */
  82266. maxIssues?: number;
  82267. /** Ignored issues */
  82268. ignoredIssues?: Array<string>;
  82269. /** Value to override severy settings */
  82270. severityOverrides?: Object;
  82271. }
  82272. /**
  82273. * The glTF validator object
  82274. * @ignore
  82275. */
  82276. interface IGLTFValidator {
  82277. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82278. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82279. }
  82280. }
  82281. declare module BABYLON {
  82282. /** @hidden */
  82283. export var cellPixelShader: {
  82284. name: string;
  82285. shader: string;
  82286. };
  82287. }
  82288. declare module BABYLON {
  82289. /** @hidden */
  82290. export var cellVertexShader: {
  82291. name: string;
  82292. shader: string;
  82293. };
  82294. }
  82295. declare module BABYLON {
  82296. export class CellMaterial extends BABYLON.PushMaterial {
  82297. private _diffuseTexture;
  82298. diffuseTexture: BABYLON.BaseTexture;
  82299. diffuseColor: BABYLON.Color3;
  82300. _computeHighLevel: boolean;
  82301. computeHighLevel: boolean;
  82302. private _disableLighting;
  82303. disableLighting: boolean;
  82304. private _maxSimultaneousLights;
  82305. maxSimultaneousLights: number;
  82306. constructor(name: string, scene: BABYLON.Scene);
  82307. needAlphaBlending(): boolean;
  82308. needAlphaTesting(): boolean;
  82309. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82310. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82311. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82312. getAnimatables(): BABYLON.IAnimatable[];
  82313. getActiveTextures(): BABYLON.BaseTexture[];
  82314. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82315. dispose(forceDisposeEffect?: boolean): void;
  82316. getClassName(): string;
  82317. clone(name: string): CellMaterial;
  82318. serialize(): any;
  82319. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82320. }
  82321. }
  82322. declare module BABYLON {
  82323. export class CustomShaderStructure {
  82324. FragmentStore: string;
  82325. VertexStore: string;
  82326. constructor();
  82327. }
  82328. export class ShaderSpecialParts {
  82329. constructor();
  82330. Fragment_Begin: string;
  82331. Fragment_Definitions: string;
  82332. Fragment_MainBegin: string;
  82333. Fragment_Custom_Diffuse: string;
  82334. Fragment_Before_Lights: string;
  82335. Fragment_Before_Fog: string;
  82336. Fragment_Custom_Alpha: string;
  82337. Fragment_Before_FragColor: string;
  82338. Vertex_Begin: string;
  82339. Vertex_Definitions: string;
  82340. Vertex_MainBegin: string;
  82341. Vertex_Before_PositionUpdated: string;
  82342. Vertex_Before_NormalUpdated: string;
  82343. Vertex_After_WorldPosComputed: string;
  82344. Vertex_MainEnd: string;
  82345. }
  82346. export class CustomMaterial extends BABYLON.StandardMaterial {
  82347. static ShaderIndexer: number;
  82348. CustomParts: ShaderSpecialParts;
  82349. _isCreatedShader: boolean;
  82350. _createdShaderName: string;
  82351. _customUniform: string[];
  82352. _newUniforms: string[];
  82353. _newUniformInstances: {
  82354. [name: string]: any;
  82355. };
  82356. _newSamplerInstances: {
  82357. [name: string]: BABYLON.Texture;
  82358. };
  82359. _customAttributes: string[];
  82360. FragmentShader: string;
  82361. VertexShader: string;
  82362. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82363. ReviewUniform(name: string, arr: string[]): string[];
  82364. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82365. constructor(name: string, scene: BABYLON.Scene);
  82366. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82367. AddAttribute(name: string): CustomMaterial;
  82368. Fragment_Begin(shaderPart: string): CustomMaterial;
  82369. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82370. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82371. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82372. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82373. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82374. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82375. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82376. Vertex_Begin(shaderPart: string): CustomMaterial;
  82377. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82378. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82379. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82380. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82381. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82382. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82383. }
  82384. }
  82385. declare module BABYLON {
  82386. export class ShaderAlebdoParts {
  82387. constructor();
  82388. Fragment_Begin: string;
  82389. Fragment_Definitions: string;
  82390. Fragment_MainBegin: string;
  82391. Fragment_Custom_Albedo: string;
  82392. Fragment_Before_Lights: string;
  82393. Fragment_Custom_MetallicRoughness: string;
  82394. Fragment_Custom_MicroSurface: string;
  82395. Fragment_Before_Fog: string;
  82396. Fragment_Custom_Alpha: string;
  82397. Fragment_Before_FragColor: string;
  82398. Vertex_Begin: string;
  82399. Vertex_Definitions: string;
  82400. Vertex_MainBegin: string;
  82401. Vertex_Before_PositionUpdated: string;
  82402. Vertex_Before_NormalUpdated: string;
  82403. Vertex_After_WorldPosComputed: string;
  82404. Vertex_MainEnd: string;
  82405. }
  82406. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  82407. static ShaderIndexer: number;
  82408. CustomParts: ShaderAlebdoParts;
  82409. _isCreatedShader: boolean;
  82410. _createdShaderName: string;
  82411. _customUniform: string[];
  82412. _newUniforms: string[];
  82413. _newUniformInstances: {
  82414. [name: string]: any;
  82415. };
  82416. _newSamplerInstances: {
  82417. [name: string]: BABYLON.Texture;
  82418. };
  82419. _customAttributes: string[];
  82420. FragmentShader: string;
  82421. VertexShader: string;
  82422. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82423. ReviewUniform(name: string, arr: string[]): string[];
  82424. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82425. constructor(name: string, scene: BABYLON.Scene);
  82426. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  82427. AddAttribute(name: string): PBRCustomMaterial;
  82428. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  82429. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  82430. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  82431. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  82432. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  82433. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  82434. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  82435. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  82436. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  82437. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  82438. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  82439. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  82440. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  82441. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  82442. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  82443. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  82444. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  82445. }
  82446. }
  82447. declare module BABYLON {
  82448. /** @hidden */
  82449. export var firePixelShader: {
  82450. name: string;
  82451. shader: string;
  82452. };
  82453. }
  82454. declare module BABYLON {
  82455. /** @hidden */
  82456. export var fireVertexShader: {
  82457. name: string;
  82458. shader: string;
  82459. };
  82460. }
  82461. declare module BABYLON {
  82462. export class FireMaterial extends BABYLON.PushMaterial {
  82463. private _diffuseTexture;
  82464. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82465. private _distortionTexture;
  82466. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82467. private _opacityTexture;
  82468. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82469. diffuseColor: BABYLON.Color3;
  82470. speed: number;
  82471. private _scaledDiffuse;
  82472. private _lastTime;
  82473. constructor(name: string, scene: BABYLON.Scene);
  82474. needAlphaBlending(): boolean;
  82475. needAlphaTesting(): boolean;
  82476. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82477. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82478. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82479. getAnimatables(): BABYLON.IAnimatable[];
  82480. getActiveTextures(): BABYLON.BaseTexture[];
  82481. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82482. getClassName(): string;
  82483. dispose(forceDisposeEffect?: boolean): void;
  82484. clone(name: string): FireMaterial;
  82485. serialize(): any;
  82486. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  82487. }
  82488. }
  82489. declare module BABYLON {
  82490. /** @hidden */
  82491. export var furPixelShader: {
  82492. name: string;
  82493. shader: string;
  82494. };
  82495. }
  82496. declare module BABYLON {
  82497. /** @hidden */
  82498. export var furVertexShader: {
  82499. name: string;
  82500. shader: string;
  82501. };
  82502. }
  82503. declare module BABYLON {
  82504. export class FurMaterial extends BABYLON.PushMaterial {
  82505. private _diffuseTexture;
  82506. diffuseTexture: BABYLON.BaseTexture;
  82507. private _heightTexture;
  82508. heightTexture: BABYLON.BaseTexture;
  82509. diffuseColor: BABYLON.Color3;
  82510. furLength: number;
  82511. furAngle: number;
  82512. furColor: BABYLON.Color3;
  82513. furOffset: number;
  82514. furSpacing: number;
  82515. furGravity: BABYLON.Vector3;
  82516. furSpeed: number;
  82517. furDensity: number;
  82518. furOcclusion: number;
  82519. furTexture: BABYLON.DynamicTexture;
  82520. private _disableLighting;
  82521. disableLighting: boolean;
  82522. private _maxSimultaneousLights;
  82523. maxSimultaneousLights: number;
  82524. highLevelFur: boolean;
  82525. _meshes: BABYLON.AbstractMesh[];
  82526. private _furTime;
  82527. constructor(name: string, scene: BABYLON.Scene);
  82528. get furTime(): number;
  82529. set furTime(furTime: number);
  82530. needAlphaBlending(): boolean;
  82531. needAlphaTesting(): boolean;
  82532. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82533. updateFur(): void;
  82534. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82535. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82536. getAnimatables(): BABYLON.IAnimatable[];
  82537. getActiveTextures(): BABYLON.BaseTexture[];
  82538. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82539. dispose(forceDisposeEffect?: boolean): void;
  82540. clone(name: string): FurMaterial;
  82541. serialize(): any;
  82542. getClassName(): string;
  82543. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  82544. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  82545. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  82546. }
  82547. }
  82548. declare module BABYLON {
  82549. /** @hidden */
  82550. export var gradientPixelShader: {
  82551. name: string;
  82552. shader: string;
  82553. };
  82554. }
  82555. declare module BABYLON {
  82556. /** @hidden */
  82557. export var gradientVertexShader: {
  82558. name: string;
  82559. shader: string;
  82560. };
  82561. }
  82562. declare module BABYLON {
  82563. export class GradientMaterial extends BABYLON.PushMaterial {
  82564. private _maxSimultaneousLights;
  82565. maxSimultaneousLights: number;
  82566. topColor: BABYLON.Color3;
  82567. topColorAlpha: number;
  82568. bottomColor: BABYLON.Color3;
  82569. bottomColorAlpha: number;
  82570. offset: number;
  82571. scale: number;
  82572. smoothness: number;
  82573. private _disableLighting;
  82574. disableLighting: boolean;
  82575. constructor(name: string, scene: BABYLON.Scene);
  82576. needAlphaBlending(): boolean;
  82577. needAlphaTesting(): boolean;
  82578. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82579. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82580. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82581. getAnimatables(): BABYLON.IAnimatable[];
  82582. dispose(forceDisposeEffect?: boolean): void;
  82583. clone(name: string): GradientMaterial;
  82584. serialize(): any;
  82585. getClassName(): string;
  82586. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  82587. }
  82588. }
  82589. declare module BABYLON {
  82590. /** @hidden */
  82591. export var gridPixelShader: {
  82592. name: string;
  82593. shader: string;
  82594. };
  82595. }
  82596. declare module BABYLON {
  82597. /** @hidden */
  82598. export var gridVertexShader: {
  82599. name: string;
  82600. shader: string;
  82601. };
  82602. }
  82603. declare module BABYLON {
  82604. /**
  82605. * The grid materials allows you to wrap any shape with a grid.
  82606. * Colors are customizable.
  82607. */
  82608. export class GridMaterial extends BABYLON.PushMaterial {
  82609. /**
  82610. * Main color of the grid (e.g. between lines)
  82611. */
  82612. mainColor: BABYLON.Color3;
  82613. /**
  82614. * Color of the grid lines.
  82615. */
  82616. lineColor: BABYLON.Color3;
  82617. /**
  82618. * The scale of the grid compared to unit.
  82619. */
  82620. gridRatio: number;
  82621. /**
  82622. * Allows setting an offset for the grid lines.
  82623. */
  82624. gridOffset: BABYLON.Vector3;
  82625. /**
  82626. * The frequency of thicker lines.
  82627. */
  82628. majorUnitFrequency: number;
  82629. /**
  82630. * The visibility of minor units in the grid.
  82631. */
  82632. minorUnitVisibility: number;
  82633. /**
  82634. * The grid opacity outside of the lines.
  82635. */
  82636. opacity: number;
  82637. /**
  82638. * Determine RBG output is premultiplied by alpha value.
  82639. */
  82640. preMultiplyAlpha: boolean;
  82641. private _opacityTexture;
  82642. opacityTexture: BABYLON.BaseTexture;
  82643. private _gridControl;
  82644. /**
  82645. * constructor
  82646. * @param name The name given to the material in order to identify it afterwards.
  82647. * @param scene The scene the material is used in.
  82648. */
  82649. constructor(name: string, scene: BABYLON.Scene);
  82650. /**
  82651. * Returns wehter or not the grid requires alpha blending.
  82652. */
  82653. needAlphaBlending(): boolean;
  82654. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82655. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82656. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82657. /**
  82658. * Dispose the material and its associated resources.
  82659. * @param forceDisposeEffect will also dispose the used effect when true
  82660. */
  82661. dispose(forceDisposeEffect?: boolean): void;
  82662. clone(name: string): GridMaterial;
  82663. serialize(): any;
  82664. getClassName(): string;
  82665. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  82666. }
  82667. }
  82668. declare module BABYLON {
  82669. /** @hidden */
  82670. export var lavaPixelShader: {
  82671. name: string;
  82672. shader: string;
  82673. };
  82674. }
  82675. declare module BABYLON {
  82676. /** @hidden */
  82677. export var lavaVertexShader: {
  82678. name: string;
  82679. shader: string;
  82680. };
  82681. }
  82682. declare module BABYLON {
  82683. export class LavaMaterial extends BABYLON.PushMaterial {
  82684. private _diffuseTexture;
  82685. diffuseTexture: BABYLON.BaseTexture;
  82686. noiseTexture: BABYLON.BaseTexture;
  82687. fogColor: BABYLON.Color3;
  82688. speed: number;
  82689. movingSpeed: number;
  82690. lowFrequencySpeed: number;
  82691. fogDensity: number;
  82692. private _lastTime;
  82693. diffuseColor: BABYLON.Color3;
  82694. private _disableLighting;
  82695. disableLighting: boolean;
  82696. private _unlit;
  82697. unlit: boolean;
  82698. private _maxSimultaneousLights;
  82699. maxSimultaneousLights: number;
  82700. private _scaledDiffuse;
  82701. constructor(name: string, scene: BABYLON.Scene);
  82702. needAlphaBlending(): boolean;
  82703. needAlphaTesting(): boolean;
  82704. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82705. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82706. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82707. getAnimatables(): BABYLON.IAnimatable[];
  82708. getActiveTextures(): BABYLON.BaseTexture[];
  82709. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82710. dispose(forceDisposeEffect?: boolean): void;
  82711. clone(name: string): LavaMaterial;
  82712. serialize(): any;
  82713. getClassName(): string;
  82714. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  82715. }
  82716. }
  82717. declare module BABYLON {
  82718. /** @hidden */
  82719. export var mixPixelShader: {
  82720. name: string;
  82721. shader: string;
  82722. };
  82723. }
  82724. declare module BABYLON {
  82725. /** @hidden */
  82726. export var mixVertexShader: {
  82727. name: string;
  82728. shader: string;
  82729. };
  82730. }
  82731. declare module BABYLON {
  82732. export class MixMaterial extends BABYLON.PushMaterial {
  82733. /**
  82734. * Mix textures
  82735. */
  82736. private _mixTexture1;
  82737. mixTexture1: BABYLON.BaseTexture;
  82738. private _mixTexture2;
  82739. mixTexture2: BABYLON.BaseTexture;
  82740. /**
  82741. * Diffuse textures
  82742. */
  82743. private _diffuseTexture1;
  82744. diffuseTexture1: BABYLON.Texture;
  82745. private _diffuseTexture2;
  82746. diffuseTexture2: BABYLON.Texture;
  82747. private _diffuseTexture3;
  82748. diffuseTexture3: BABYLON.Texture;
  82749. private _diffuseTexture4;
  82750. diffuseTexture4: BABYLON.Texture;
  82751. private _diffuseTexture5;
  82752. diffuseTexture5: BABYLON.Texture;
  82753. private _diffuseTexture6;
  82754. diffuseTexture6: BABYLON.Texture;
  82755. private _diffuseTexture7;
  82756. diffuseTexture7: BABYLON.Texture;
  82757. private _diffuseTexture8;
  82758. diffuseTexture8: BABYLON.Texture;
  82759. /**
  82760. * Uniforms
  82761. */
  82762. diffuseColor: BABYLON.Color3;
  82763. specularColor: BABYLON.Color3;
  82764. specularPower: number;
  82765. private _disableLighting;
  82766. disableLighting: boolean;
  82767. private _maxSimultaneousLights;
  82768. maxSimultaneousLights: number;
  82769. constructor(name: string, scene: BABYLON.Scene);
  82770. needAlphaBlending(): boolean;
  82771. needAlphaTesting(): boolean;
  82772. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82773. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82774. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82775. getAnimatables(): BABYLON.IAnimatable[];
  82776. getActiveTextures(): BABYLON.BaseTexture[];
  82777. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82778. dispose(forceDisposeEffect?: boolean): void;
  82779. clone(name: string): MixMaterial;
  82780. serialize(): any;
  82781. getClassName(): string;
  82782. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  82783. }
  82784. }
  82785. declare module BABYLON {
  82786. /** @hidden */
  82787. export var normalPixelShader: {
  82788. name: string;
  82789. shader: string;
  82790. };
  82791. }
  82792. declare module BABYLON {
  82793. /** @hidden */
  82794. export var normalVertexShader: {
  82795. name: string;
  82796. shader: string;
  82797. };
  82798. }
  82799. declare module BABYLON {
  82800. export class NormalMaterial extends BABYLON.PushMaterial {
  82801. private _diffuseTexture;
  82802. diffuseTexture: BABYLON.BaseTexture;
  82803. diffuseColor: BABYLON.Color3;
  82804. private _disableLighting;
  82805. disableLighting: boolean;
  82806. private _maxSimultaneousLights;
  82807. maxSimultaneousLights: number;
  82808. constructor(name: string, scene: BABYLON.Scene);
  82809. needAlphaBlending(): boolean;
  82810. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  82811. needAlphaTesting(): boolean;
  82812. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82813. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82814. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82815. getAnimatables(): BABYLON.IAnimatable[];
  82816. getActiveTextures(): BABYLON.BaseTexture[];
  82817. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82818. dispose(forceDisposeEffect?: boolean): void;
  82819. clone(name: string): NormalMaterial;
  82820. serialize(): any;
  82821. getClassName(): string;
  82822. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  82823. }
  82824. }
  82825. declare module BABYLON {
  82826. /** @hidden */
  82827. export var shadowOnlyPixelShader: {
  82828. name: string;
  82829. shader: string;
  82830. };
  82831. }
  82832. declare module BABYLON {
  82833. /** @hidden */
  82834. export var shadowOnlyVertexShader: {
  82835. name: string;
  82836. shader: string;
  82837. };
  82838. }
  82839. declare module BABYLON {
  82840. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  82841. private _activeLight;
  82842. private _needAlphaBlending;
  82843. constructor(name: string, scene: BABYLON.Scene);
  82844. shadowColor: BABYLON.Color3;
  82845. needAlphaBlending(): boolean;
  82846. needAlphaTesting(): boolean;
  82847. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82848. get activeLight(): BABYLON.IShadowLight;
  82849. set activeLight(light: BABYLON.IShadowLight);
  82850. private _getFirstShadowLightForMesh;
  82851. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82852. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82853. clone(name: string): ShadowOnlyMaterial;
  82854. serialize(): any;
  82855. getClassName(): string;
  82856. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  82857. }
  82858. }
  82859. declare module BABYLON {
  82860. /** @hidden */
  82861. export var simplePixelShader: {
  82862. name: string;
  82863. shader: string;
  82864. };
  82865. }
  82866. declare module BABYLON {
  82867. /** @hidden */
  82868. export var simpleVertexShader: {
  82869. name: string;
  82870. shader: string;
  82871. };
  82872. }
  82873. declare module BABYLON {
  82874. export class SimpleMaterial extends BABYLON.PushMaterial {
  82875. private _diffuseTexture;
  82876. diffuseTexture: BABYLON.BaseTexture;
  82877. diffuseColor: BABYLON.Color3;
  82878. private _disableLighting;
  82879. disableLighting: boolean;
  82880. private _maxSimultaneousLights;
  82881. maxSimultaneousLights: number;
  82882. constructor(name: string, scene: BABYLON.Scene);
  82883. needAlphaBlending(): boolean;
  82884. needAlphaTesting(): boolean;
  82885. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82886. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82887. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82888. getAnimatables(): BABYLON.IAnimatable[];
  82889. getActiveTextures(): BABYLON.BaseTexture[];
  82890. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82891. dispose(forceDisposeEffect?: boolean): void;
  82892. clone(name: string): SimpleMaterial;
  82893. serialize(): any;
  82894. getClassName(): string;
  82895. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  82896. }
  82897. }
  82898. declare module BABYLON {
  82899. /** @hidden */
  82900. export var skyPixelShader: {
  82901. name: string;
  82902. shader: string;
  82903. };
  82904. }
  82905. declare module BABYLON {
  82906. /** @hidden */
  82907. export var skyVertexShader: {
  82908. name: string;
  82909. shader: string;
  82910. };
  82911. }
  82912. declare module BABYLON {
  82913. /**
  82914. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  82915. * @see https://doc.babylonjs.com/extensions/sky
  82916. */
  82917. export class SkyMaterial extends BABYLON.PushMaterial {
  82918. /**
  82919. * Defines the overall luminance of sky in interval ]0, 1[.
  82920. */
  82921. luminance: number;
  82922. /**
  82923. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  82924. */
  82925. turbidity: number;
  82926. /**
  82927. * Defines the sky appearance (light intensity).
  82928. */
  82929. rayleigh: number;
  82930. /**
  82931. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  82932. */
  82933. mieCoefficient: number;
  82934. /**
  82935. * Defines the amount of haze particles following the Mie scattering theory.
  82936. */
  82937. mieDirectionalG: number;
  82938. /**
  82939. * Defines the distance of the sun according to the active scene camera.
  82940. */
  82941. distance: number;
  82942. /**
  82943. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  82944. * "inclined".
  82945. */
  82946. inclination: number;
  82947. /**
  82948. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  82949. * an object direction and a reference direction.
  82950. */
  82951. azimuth: number;
  82952. /**
  82953. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  82954. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  82955. */
  82956. sunPosition: BABYLON.Vector3;
  82957. /**
  82958. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  82959. * .sunPosition property.
  82960. */
  82961. useSunPosition: boolean;
  82962. /**
  82963. * Defines an offset vector used to get a horizon offset.
  82964. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  82965. */
  82966. cameraOffset: BABYLON.Vector3;
  82967. private _cameraPosition;
  82968. /**
  82969. * Instantiates a new sky material.
  82970. * This material allows to create dynamic and texture free
  82971. * effects for skyboxes by taking care of the atmosphere state.
  82972. * @see https://doc.babylonjs.com/extensions/sky
  82973. * @param name Define the name of the material in the scene
  82974. * @param scene Define the scene the material belong to
  82975. */
  82976. constructor(name: string, scene: BABYLON.Scene);
  82977. /**
  82978. * Specifies if the material will require alpha blending
  82979. * @returns a boolean specifying if alpha blending is needed
  82980. */
  82981. needAlphaBlending(): boolean;
  82982. /**
  82983. * Specifies if this material should be rendered in alpha test mode
  82984. * @returns false as the sky material doesn't need alpha testing.
  82985. */
  82986. needAlphaTesting(): boolean;
  82987. /**
  82988. * Get the texture used for alpha test purpose.
  82989. * @returns null as the sky material has no texture.
  82990. */
  82991. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82992. /**
  82993. * Get if the submesh is ready to be used and all its information available.
  82994. * Child classes can use it to update shaders
  82995. * @param mesh defines the mesh to check
  82996. * @param subMesh defines which submesh to check
  82997. * @param useInstances specifies that instances should be used
  82998. * @returns a boolean indicating that the submesh is ready or not
  82999. */
  83000. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83001. /**
  83002. * Binds the submesh to this material by preparing the effect and shader to draw
  83003. * @param world defines the world transformation matrix
  83004. * @param mesh defines the mesh containing the submesh
  83005. * @param subMesh defines the submesh to bind the material to
  83006. */
  83007. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83008. /**
  83009. * Get the list of animatables in the material.
  83010. * @returns the list of animatables object used in the material
  83011. */
  83012. getAnimatables(): BABYLON.IAnimatable[];
  83013. /**
  83014. * Disposes the material
  83015. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83016. */
  83017. dispose(forceDisposeEffect?: boolean): void;
  83018. /**
  83019. * Makes a duplicate of the material, and gives it a new name
  83020. * @param name defines the new name for the duplicated material
  83021. * @returns the cloned material
  83022. */
  83023. clone(name: string): SkyMaterial;
  83024. /**
  83025. * Serializes this material in a JSON representation
  83026. * @returns the serialized material object
  83027. */
  83028. serialize(): any;
  83029. /**
  83030. * Gets the current class name of the material e.g. "SkyMaterial"
  83031. * Mainly use in serialization.
  83032. * @returns the class name
  83033. */
  83034. getClassName(): string;
  83035. /**
  83036. * Creates a sky material from parsed material data
  83037. * @param source defines the JSON representation of the material
  83038. * @param scene defines the hosting scene
  83039. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83040. * @returns a new sky material
  83041. */
  83042. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  83043. }
  83044. }
  83045. declare module BABYLON {
  83046. /** @hidden */
  83047. export var terrainPixelShader: {
  83048. name: string;
  83049. shader: string;
  83050. };
  83051. }
  83052. declare module BABYLON {
  83053. /** @hidden */
  83054. export var terrainVertexShader: {
  83055. name: string;
  83056. shader: string;
  83057. };
  83058. }
  83059. declare module BABYLON {
  83060. export class TerrainMaterial extends BABYLON.PushMaterial {
  83061. private _mixTexture;
  83062. mixTexture: BABYLON.BaseTexture;
  83063. private _diffuseTexture1;
  83064. diffuseTexture1: BABYLON.Texture;
  83065. private _diffuseTexture2;
  83066. diffuseTexture2: BABYLON.Texture;
  83067. private _diffuseTexture3;
  83068. diffuseTexture3: BABYLON.Texture;
  83069. private _bumpTexture1;
  83070. bumpTexture1: BABYLON.Texture;
  83071. private _bumpTexture2;
  83072. bumpTexture2: BABYLON.Texture;
  83073. private _bumpTexture3;
  83074. bumpTexture3: BABYLON.Texture;
  83075. diffuseColor: BABYLON.Color3;
  83076. specularColor: BABYLON.Color3;
  83077. specularPower: number;
  83078. private _disableLighting;
  83079. disableLighting: boolean;
  83080. private _maxSimultaneousLights;
  83081. maxSimultaneousLights: number;
  83082. constructor(name: string, scene: BABYLON.Scene);
  83083. needAlphaBlending(): boolean;
  83084. needAlphaTesting(): boolean;
  83085. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83086. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83087. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83088. getAnimatables(): BABYLON.IAnimatable[];
  83089. getActiveTextures(): BABYLON.BaseTexture[];
  83090. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83091. dispose(forceDisposeEffect?: boolean): void;
  83092. clone(name: string): TerrainMaterial;
  83093. serialize(): any;
  83094. getClassName(): string;
  83095. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  83096. }
  83097. }
  83098. declare module BABYLON {
  83099. /** @hidden */
  83100. export var triplanarPixelShader: {
  83101. name: string;
  83102. shader: string;
  83103. };
  83104. }
  83105. declare module BABYLON {
  83106. /** @hidden */
  83107. export var triplanarVertexShader: {
  83108. name: string;
  83109. shader: string;
  83110. };
  83111. }
  83112. declare module BABYLON {
  83113. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  83114. mixTexture: BABYLON.BaseTexture;
  83115. private _diffuseTextureX;
  83116. diffuseTextureX: BABYLON.BaseTexture;
  83117. private _diffuseTextureY;
  83118. diffuseTextureY: BABYLON.BaseTexture;
  83119. private _diffuseTextureZ;
  83120. diffuseTextureZ: BABYLON.BaseTexture;
  83121. private _normalTextureX;
  83122. normalTextureX: BABYLON.BaseTexture;
  83123. private _normalTextureY;
  83124. normalTextureY: BABYLON.BaseTexture;
  83125. private _normalTextureZ;
  83126. normalTextureZ: BABYLON.BaseTexture;
  83127. tileSize: number;
  83128. diffuseColor: BABYLON.Color3;
  83129. specularColor: BABYLON.Color3;
  83130. specularPower: number;
  83131. private _disableLighting;
  83132. disableLighting: boolean;
  83133. private _maxSimultaneousLights;
  83134. maxSimultaneousLights: number;
  83135. constructor(name: string, scene: BABYLON.Scene);
  83136. needAlphaBlending(): boolean;
  83137. needAlphaTesting(): boolean;
  83138. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83139. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83140. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83141. getAnimatables(): BABYLON.IAnimatable[];
  83142. getActiveTextures(): BABYLON.BaseTexture[];
  83143. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83144. dispose(forceDisposeEffect?: boolean): void;
  83145. clone(name: string): TriPlanarMaterial;
  83146. serialize(): any;
  83147. getClassName(): string;
  83148. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83149. }
  83150. }
  83151. declare module BABYLON {
  83152. /** @hidden */
  83153. export var waterPixelShader: {
  83154. name: string;
  83155. shader: string;
  83156. };
  83157. }
  83158. declare module BABYLON {
  83159. /** @hidden */
  83160. export var waterVertexShader: {
  83161. name: string;
  83162. shader: string;
  83163. };
  83164. }
  83165. declare module BABYLON {
  83166. export class WaterMaterial extends BABYLON.PushMaterial {
  83167. renderTargetSize: BABYLON.Vector2;
  83168. private _bumpTexture;
  83169. bumpTexture: BABYLON.BaseTexture;
  83170. diffuseColor: BABYLON.Color3;
  83171. specularColor: BABYLON.Color3;
  83172. specularPower: number;
  83173. private _disableLighting;
  83174. disableLighting: boolean;
  83175. private _maxSimultaneousLights;
  83176. maxSimultaneousLights: number;
  83177. /**
  83178. * @param {number}: Represents the wind force
  83179. */
  83180. windForce: number;
  83181. /**
  83182. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83183. */
  83184. windDirection: BABYLON.Vector2;
  83185. /**
  83186. * @param {number}: Wave height, represents the height of the waves
  83187. */
  83188. waveHeight: number;
  83189. /**
  83190. * @param {number}: Bump height, represents the bump height related to the bump map
  83191. */
  83192. bumpHeight: number;
  83193. /**
  83194. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83195. */
  83196. private _bumpSuperimpose;
  83197. bumpSuperimpose: boolean;
  83198. /**
  83199. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83200. */
  83201. private _fresnelSeparate;
  83202. fresnelSeparate: boolean;
  83203. /**
  83204. * @param {boolean}: bump Waves modify the reflection.
  83205. */
  83206. private _bumpAffectsReflection;
  83207. bumpAffectsReflection: boolean;
  83208. /**
  83209. * @param {number}: The water color blended with the refraction (near)
  83210. */
  83211. waterColor: BABYLON.Color3;
  83212. /**
  83213. * @param {number}: The blend factor related to the water color
  83214. */
  83215. colorBlendFactor: number;
  83216. /**
  83217. * @param {number}: The water color blended with the reflection (far)
  83218. */
  83219. waterColor2: BABYLON.Color3;
  83220. /**
  83221. * @param {number}: The blend factor related to the water color (reflection, far)
  83222. */
  83223. colorBlendFactor2: number;
  83224. /**
  83225. * @param {number}: Represents the maximum length of a wave
  83226. */
  83227. waveLength: number;
  83228. /**
  83229. * @param {number}: Defines the waves speed
  83230. */
  83231. waveSpeed: number;
  83232. /**
  83233. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83234. * will avoid calculating useless pixels in the pixel shader of the water material.
  83235. */
  83236. disableClipPlane: boolean;
  83237. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83238. private _mesh;
  83239. private _refractionRTT;
  83240. private _reflectionRTT;
  83241. private _reflectionTransform;
  83242. private _lastTime;
  83243. private _lastDeltaTime;
  83244. private _useLogarithmicDepth;
  83245. private _waitingRenderList;
  83246. private _imageProcessingConfiguration;
  83247. private _imageProcessingObserver;
  83248. /**
  83249. * Gets a boolean indicating that current material needs to register RTT
  83250. */
  83251. get hasRenderTargetTextures(): boolean;
  83252. /**
  83253. * Constructor
  83254. */
  83255. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83256. get useLogarithmicDepth(): boolean;
  83257. set useLogarithmicDepth(value: boolean);
  83258. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83259. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83260. addToRenderList(node: any): void;
  83261. enableRenderTargets(enable: boolean): void;
  83262. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83263. get renderTargetsEnabled(): boolean;
  83264. needAlphaBlending(): boolean;
  83265. needAlphaTesting(): boolean;
  83266. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83267. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83268. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83269. private _createRenderTargets;
  83270. getAnimatables(): BABYLON.IAnimatable[];
  83271. getActiveTextures(): BABYLON.BaseTexture[];
  83272. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83273. dispose(forceDisposeEffect?: boolean): void;
  83274. clone(name: string): WaterMaterial;
  83275. serialize(): any;
  83276. getClassName(): string;
  83277. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83278. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83279. }
  83280. }
  83281. declare module BABYLON {
  83282. /** @hidden */
  83283. export var asciiartPixelShader: {
  83284. name: string;
  83285. shader: string;
  83286. };
  83287. }
  83288. declare module BABYLON {
  83289. /**
  83290. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83291. *
  83292. * It basically takes care rendering the font front the given font size to a texture.
  83293. * This is used later on in the postprocess.
  83294. */
  83295. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83296. private _font;
  83297. private _text;
  83298. private _charSize;
  83299. /**
  83300. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83301. */
  83302. get charSize(): number;
  83303. /**
  83304. * Create a new instance of the Ascii Art FontTexture class
  83305. * @param name the name of the texture
  83306. * @param font the font to use, use the W3C CSS notation
  83307. * @param text the caracter set to use in the rendering.
  83308. * @param scene the scene that owns the texture
  83309. */
  83310. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83311. /**
  83312. * Gets the max char width of a font.
  83313. * @param font the font to use, use the W3C CSS notation
  83314. * @return the max char width
  83315. */
  83316. private getFontWidth;
  83317. /**
  83318. * Gets the max char height of a font.
  83319. * @param font the font to use, use the W3C CSS notation
  83320. * @return the max char height
  83321. */
  83322. private getFontHeight;
  83323. /**
  83324. * Clones the current AsciiArtTexture.
  83325. * @return the clone of the texture.
  83326. */
  83327. clone(): AsciiArtFontTexture;
  83328. /**
  83329. * Parses a json object representing the texture and returns an instance of it.
  83330. * @param source the source JSON representation
  83331. * @param scene the scene to create the texture for
  83332. * @return the parsed texture
  83333. */
  83334. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83335. }
  83336. /**
  83337. * Option available in the Ascii Art Post Process.
  83338. */
  83339. export interface IAsciiArtPostProcessOptions {
  83340. /**
  83341. * The font to use following the w3c font definition.
  83342. */
  83343. font?: string;
  83344. /**
  83345. * The character set to use in the postprocess.
  83346. */
  83347. characterSet?: string;
  83348. /**
  83349. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83350. * This number is defined between 0 and 1;
  83351. */
  83352. mixToTile?: number;
  83353. /**
  83354. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83355. * This number is defined between 0 and 1;
  83356. */
  83357. mixToNormal?: number;
  83358. }
  83359. /**
  83360. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83361. *
  83362. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83363. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83364. */
  83365. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83366. /**
  83367. * The font texture used to render the char in the post process.
  83368. */
  83369. private _asciiArtFontTexture;
  83370. /**
  83371. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83372. * This number is defined between 0 and 1;
  83373. */
  83374. mixToTile: number;
  83375. /**
  83376. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83377. * This number is defined between 0 and 1;
  83378. */
  83379. mixToNormal: number;
  83380. /**
  83381. * Instantiates a new Ascii Art Post Process.
  83382. * @param name the name to give to the postprocess
  83383. * @camera the camera to apply the post process to.
  83384. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83385. */
  83386. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83387. }
  83388. }
  83389. declare module BABYLON {
  83390. /** @hidden */
  83391. export var digitalrainPixelShader: {
  83392. name: string;
  83393. shader: string;
  83394. };
  83395. }
  83396. declare module BABYLON {
  83397. /**
  83398. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83399. *
  83400. * It basically takes care rendering the font front the given font size to a texture.
  83401. * This is used later on in the postprocess.
  83402. */
  83403. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  83404. private _font;
  83405. private _text;
  83406. private _charSize;
  83407. /**
  83408. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83409. */
  83410. get charSize(): number;
  83411. /**
  83412. * Create a new instance of the Digital Rain FontTexture class
  83413. * @param name the name of the texture
  83414. * @param font the font to use, use the W3C CSS notation
  83415. * @param text the caracter set to use in the rendering.
  83416. * @param scene the scene that owns the texture
  83417. */
  83418. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83419. /**
  83420. * Gets the max char width of a font.
  83421. * @param font the font to use, use the W3C CSS notation
  83422. * @return the max char width
  83423. */
  83424. private getFontWidth;
  83425. /**
  83426. * Gets the max char height of a font.
  83427. * @param font the font to use, use the W3C CSS notation
  83428. * @return the max char height
  83429. */
  83430. private getFontHeight;
  83431. /**
  83432. * Clones the current DigitalRainFontTexture.
  83433. * @return the clone of the texture.
  83434. */
  83435. clone(): DigitalRainFontTexture;
  83436. /**
  83437. * Parses a json object representing the texture and returns an instance of it.
  83438. * @param source the source JSON representation
  83439. * @param scene the scene to create the texture for
  83440. * @return the parsed texture
  83441. */
  83442. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  83443. }
  83444. /**
  83445. * Option available in the Digital Rain Post Process.
  83446. */
  83447. export interface IDigitalRainPostProcessOptions {
  83448. /**
  83449. * The font to use following the w3c font definition.
  83450. */
  83451. font?: string;
  83452. /**
  83453. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83454. * This number is defined between 0 and 1;
  83455. */
  83456. mixToTile?: number;
  83457. /**
  83458. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83459. * This number is defined between 0 and 1;
  83460. */
  83461. mixToNormal?: number;
  83462. }
  83463. /**
  83464. * DigitalRainPostProcess helps rendering everithing in digital rain.
  83465. *
  83466. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83467. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  83468. */
  83469. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  83470. /**
  83471. * The font texture used to render the char in the post process.
  83472. */
  83473. private _digitalRainFontTexture;
  83474. /**
  83475. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  83476. * This number is defined between 0 and 1;
  83477. */
  83478. mixToTile: number;
  83479. /**
  83480. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  83481. * This number is defined between 0 and 1;
  83482. */
  83483. mixToNormal: number;
  83484. /**
  83485. * Instantiates a new Digital Rain Post Process.
  83486. * @param name the name to give to the postprocess
  83487. * @camera the camera to apply the post process to.
  83488. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  83489. */
  83490. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  83491. }
  83492. }
  83493. declare module BABYLON {
  83494. /** @hidden */
  83495. export var brickProceduralTexturePixelShader: {
  83496. name: string;
  83497. shader: string;
  83498. };
  83499. }
  83500. declare module BABYLON {
  83501. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  83502. private _numberOfBricksHeight;
  83503. private _numberOfBricksWidth;
  83504. private _jointColor;
  83505. private _brickColor;
  83506. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83507. updateShaderUniforms(): void;
  83508. get numberOfBricksHeight(): number;
  83509. set numberOfBricksHeight(value: number);
  83510. get numberOfBricksWidth(): number;
  83511. set numberOfBricksWidth(value: number);
  83512. get jointColor(): BABYLON.Color3;
  83513. set jointColor(value: BABYLON.Color3);
  83514. get brickColor(): BABYLON.Color3;
  83515. set brickColor(value: BABYLON.Color3);
  83516. /**
  83517. * Serializes this brick procedural texture
  83518. * @returns a serialized brick procedural texture object
  83519. */
  83520. serialize(): any;
  83521. /**
  83522. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  83523. * @param parsedTexture defines parsed texture data
  83524. * @param scene defines the current scene
  83525. * @param rootUrl defines the root URL containing brick procedural texture information
  83526. * @returns a parsed Brick Procedural BABYLON.Texture
  83527. */
  83528. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  83529. }
  83530. }
  83531. declare module BABYLON {
  83532. /** @hidden */
  83533. export var cloudProceduralTexturePixelShader: {
  83534. name: string;
  83535. shader: string;
  83536. };
  83537. }
  83538. declare module BABYLON {
  83539. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  83540. private _skyColor;
  83541. private _cloudColor;
  83542. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83543. updateShaderUniforms(): void;
  83544. get skyColor(): BABYLON.Color4;
  83545. set skyColor(value: BABYLON.Color4);
  83546. get cloudColor(): BABYLON.Color4;
  83547. set cloudColor(value: BABYLON.Color4);
  83548. /**
  83549. * Serializes this cloud procedural texture
  83550. * @returns a serialized cloud procedural texture object
  83551. */
  83552. serialize(): any;
  83553. /**
  83554. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  83555. * @param parsedTexture defines parsed texture data
  83556. * @param scene defines the current scene
  83557. * @param rootUrl defines the root URL containing cloud procedural texture information
  83558. * @returns a parsed Cloud Procedural BABYLON.Texture
  83559. */
  83560. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  83561. }
  83562. }
  83563. declare module BABYLON {
  83564. /** @hidden */
  83565. export var fireProceduralTexturePixelShader: {
  83566. name: string;
  83567. shader: string;
  83568. };
  83569. }
  83570. declare module BABYLON {
  83571. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  83572. private _time;
  83573. private _speed;
  83574. private _autoGenerateTime;
  83575. private _fireColors;
  83576. private _alphaThreshold;
  83577. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83578. updateShaderUniforms(): void;
  83579. render(useCameraPostProcess?: boolean): void;
  83580. static get PurpleFireColors(): BABYLON.Color3[];
  83581. static get GreenFireColors(): BABYLON.Color3[];
  83582. static get RedFireColors(): BABYLON.Color3[];
  83583. static get BlueFireColors(): BABYLON.Color3[];
  83584. get autoGenerateTime(): boolean;
  83585. set autoGenerateTime(value: boolean);
  83586. get fireColors(): BABYLON.Color3[];
  83587. set fireColors(value: BABYLON.Color3[]);
  83588. get time(): number;
  83589. set time(value: number);
  83590. get speed(): BABYLON.Vector2;
  83591. set speed(value: BABYLON.Vector2);
  83592. get alphaThreshold(): number;
  83593. set alphaThreshold(value: number);
  83594. /**
  83595. * Serializes this fire procedural texture
  83596. * @returns a serialized fire procedural texture object
  83597. */
  83598. serialize(): any;
  83599. /**
  83600. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  83601. * @param parsedTexture defines parsed texture data
  83602. * @param scene defines the current scene
  83603. * @param rootUrl defines the root URL containing fire procedural texture information
  83604. * @returns a parsed Fire Procedural BABYLON.Texture
  83605. */
  83606. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  83607. }
  83608. }
  83609. declare module BABYLON {
  83610. /** @hidden */
  83611. export var grassProceduralTexturePixelShader: {
  83612. name: string;
  83613. shader: string;
  83614. };
  83615. }
  83616. declare module BABYLON {
  83617. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  83618. private _grassColors;
  83619. private _groundColor;
  83620. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83621. updateShaderUniforms(): void;
  83622. get grassColors(): BABYLON.Color3[];
  83623. set grassColors(value: BABYLON.Color3[]);
  83624. get groundColor(): BABYLON.Color3;
  83625. set groundColor(value: BABYLON.Color3);
  83626. /**
  83627. * Serializes this grass procedural texture
  83628. * @returns a serialized grass procedural texture object
  83629. */
  83630. serialize(): any;
  83631. /**
  83632. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  83633. * @param parsedTexture defines parsed texture data
  83634. * @param scene defines the current scene
  83635. * @param rootUrl defines the root URL containing grass procedural texture information
  83636. * @returns a parsed Grass Procedural BABYLON.Texture
  83637. */
  83638. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  83639. }
  83640. }
  83641. declare module BABYLON {
  83642. /** @hidden */
  83643. export var marbleProceduralTexturePixelShader: {
  83644. name: string;
  83645. shader: string;
  83646. };
  83647. }
  83648. declare module BABYLON {
  83649. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  83650. private _numberOfTilesHeight;
  83651. private _numberOfTilesWidth;
  83652. private _amplitude;
  83653. private _jointColor;
  83654. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83655. updateShaderUniforms(): void;
  83656. get numberOfTilesHeight(): number;
  83657. set numberOfTilesHeight(value: number);
  83658. get amplitude(): number;
  83659. set amplitude(value: number);
  83660. get numberOfTilesWidth(): number;
  83661. set numberOfTilesWidth(value: number);
  83662. get jointColor(): BABYLON.Color3;
  83663. set jointColor(value: BABYLON.Color3);
  83664. /**
  83665. * Serializes this marble procedural texture
  83666. * @returns a serialized marble procedural texture object
  83667. */
  83668. serialize(): any;
  83669. /**
  83670. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  83671. * @param parsedTexture defines parsed texture data
  83672. * @param scene defines the current scene
  83673. * @param rootUrl defines the root URL containing marble procedural texture information
  83674. * @returns a parsed Marble Procedural BABYLON.Texture
  83675. */
  83676. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  83677. }
  83678. }
  83679. declare module BABYLON {
  83680. /** @hidden */
  83681. export var normalMapProceduralTexturePixelShader: {
  83682. name: string;
  83683. shader: string;
  83684. };
  83685. }
  83686. declare module BABYLON {
  83687. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  83688. private _baseTexture;
  83689. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83690. updateShaderUniforms(): void;
  83691. render(useCameraPostProcess?: boolean): void;
  83692. resize(size: any, generateMipMaps: any): void;
  83693. get baseTexture(): BABYLON.Texture;
  83694. set baseTexture(texture: BABYLON.Texture);
  83695. /**
  83696. * Serializes this normal map procedural texture
  83697. * @returns a serialized normal map procedural texture object
  83698. */
  83699. serialize(): any;
  83700. /**
  83701. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  83702. * @param parsedTexture defines parsed texture data
  83703. * @param scene defines the current scene
  83704. * @param rootUrl defines the root URL containing normal map procedural texture information
  83705. * @returns a parsed Normal Map Procedural BABYLON.Texture
  83706. */
  83707. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  83708. }
  83709. }
  83710. declare module BABYLON {
  83711. /** @hidden */
  83712. export var perlinNoiseProceduralTexturePixelShader: {
  83713. name: string;
  83714. shader: string;
  83715. };
  83716. }
  83717. declare module BABYLON {
  83718. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  83719. time: number;
  83720. timeScale: number;
  83721. translationSpeed: number;
  83722. private _currentTranslation;
  83723. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83724. updateShaderUniforms(): void;
  83725. render(useCameraPostProcess?: boolean): void;
  83726. resize(size: any, generateMipMaps: any): void;
  83727. /**
  83728. * Serializes this perlin noise procedural texture
  83729. * @returns a serialized perlin noise procedural texture object
  83730. */
  83731. serialize(): any;
  83732. /**
  83733. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  83734. * @param parsedTexture defines parsed texture data
  83735. * @param scene defines the current scene
  83736. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  83737. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  83738. */
  83739. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  83740. }
  83741. }
  83742. declare module BABYLON {
  83743. /** @hidden */
  83744. export var roadProceduralTexturePixelShader: {
  83745. name: string;
  83746. shader: string;
  83747. };
  83748. }
  83749. declare module BABYLON {
  83750. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  83751. private _roadColor;
  83752. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83753. updateShaderUniforms(): void;
  83754. get roadColor(): BABYLON.Color3;
  83755. set roadColor(value: BABYLON.Color3);
  83756. /**
  83757. * Serializes this road procedural texture
  83758. * @returns a serialized road procedural texture object
  83759. */
  83760. serialize(): any;
  83761. /**
  83762. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  83763. * @param parsedTexture defines parsed texture data
  83764. * @param scene defines the current scene
  83765. * @param rootUrl defines the root URL containing road procedural texture information
  83766. * @returns a parsed Road Procedural BABYLON.Texture
  83767. */
  83768. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  83769. }
  83770. }
  83771. declare module BABYLON {
  83772. /** @hidden */
  83773. export var starfieldProceduralTexturePixelShader: {
  83774. name: string;
  83775. shader: string;
  83776. };
  83777. }
  83778. declare module BABYLON {
  83779. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  83780. private _time;
  83781. private _alpha;
  83782. private _beta;
  83783. private _zoom;
  83784. private _formuparam;
  83785. private _stepsize;
  83786. private _tile;
  83787. private _brightness;
  83788. private _darkmatter;
  83789. private _distfading;
  83790. private _saturation;
  83791. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83792. updateShaderUniforms(): void;
  83793. get time(): number;
  83794. set time(value: number);
  83795. get alpha(): number;
  83796. set alpha(value: number);
  83797. get beta(): number;
  83798. set beta(value: number);
  83799. get formuparam(): number;
  83800. set formuparam(value: number);
  83801. get stepsize(): number;
  83802. set stepsize(value: number);
  83803. get zoom(): number;
  83804. set zoom(value: number);
  83805. get tile(): number;
  83806. set tile(value: number);
  83807. get brightness(): number;
  83808. set brightness(value: number);
  83809. get darkmatter(): number;
  83810. set darkmatter(value: number);
  83811. get distfading(): number;
  83812. set distfading(value: number);
  83813. get saturation(): number;
  83814. set saturation(value: number);
  83815. /**
  83816. * Serializes this starfield procedural texture
  83817. * @returns a serialized starfield procedural texture object
  83818. */
  83819. serialize(): any;
  83820. /**
  83821. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  83822. * @param parsedTexture defines parsed texture data
  83823. * @param scene defines the current scene
  83824. * @param rootUrl defines the root URL containing startfield procedural texture information
  83825. * @returns a parsed Starfield Procedural BABYLON.Texture
  83826. */
  83827. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  83828. }
  83829. }
  83830. declare module BABYLON {
  83831. /** @hidden */
  83832. export var woodProceduralTexturePixelShader: {
  83833. name: string;
  83834. shader: string;
  83835. };
  83836. }
  83837. declare module BABYLON {
  83838. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  83839. private _ampScale;
  83840. private _woodColor;
  83841. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  83842. updateShaderUniforms(): void;
  83843. get ampScale(): number;
  83844. set ampScale(value: number);
  83845. get woodColor(): BABYLON.Color3;
  83846. set woodColor(value: BABYLON.Color3);
  83847. /**
  83848. * Serializes this wood procedural texture
  83849. * @returns a serialized wood procedural texture object
  83850. */
  83851. serialize(): any;
  83852. /**
  83853. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  83854. * @param parsedTexture defines parsed texture data
  83855. * @param scene defines the current scene
  83856. * @param rootUrl defines the root URL containing wood procedural texture information
  83857. * @returns a parsed Wood Procedural BABYLON.Texture
  83858. */
  83859. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  83860. }
  83861. }